View Single Post

   
  #3 (permalink)  
Old 04-08-2008, 07:56 AM
G Quesnel
 
Posts: n/a
Default Re: How to get different columns total in one time query?

Take a look at the rollup and cube option on the group by.
Something like ...
Select f1,f2,count(*) from table group by cube(f1,f2);
or
Select f1,f2,f3,max(f4),count(*)
from table group by f1, f2, g3;

This last example is just to show you that you can (must) group by all
columns in the select clause which are not part of a aggregate
function, such as max or count, when you use the group by clause.

HTH

Reply With Quote