[thelist] What's wrong with my query?

Joel D Canfield joel at streamliine.com
Thu May 17 15:04:49 CDT 2007

> ID            Business_Name               Points Awarded
> ----------------------------------------------------------
> 1              tom and jerry                    15
> 2              tom and jerry                    75
> 3              tom and jerry                    20
> 4              abbott and costello        5
> 5              abbott and costello        90
> I'd like to return this result:
> tom and jerry                    110
> abbot and costello          95

    select business_name, sum(points_awarded) from yourtable
    order by business_name, group by business_name

yeah, it's even simpler than you thought. dump the subquery and do it
all at once.

(and drop the 'vw_' prefix on your view; there's no earthly reason to
nominally differentiate between the types of sql structure you're
touching any more than Browning needed to define sentence structure to
write poetry)


More information about the thelist mailing list