[thelist] SQL Query : using Group By and Order By together
rudy
r937 at interlog.com
Sat Jan 5 10:33:51 CST 2002
> see
<http://searchdatabase.techtarget.com/ateQuestionNResponse/0,289625,sid13_c
id424565_tax285649,00.html> for an example of generating total rows using
>GROUP BY and UNION ALL
[sheesh] correcting my own post
the example above does not use GROUP BY, as it generates only one "totals"
line, the overall total --
select "detail"
, a
, b
, (a + b) as sum
from yourTable
union all
select "total"
, sum(a)
, sum(b)
, sum(a + b)
from yourTable
order by 1
, 2
GROUP BY would be used if totals were required by group, but there's no
grouping here
sorry if there was any confusion
rudy
More information about the thelist
mailing list