Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

group by express

Status
Not open for further replies.

Bao

Programmer
Jul 20, 2001
3
0
0
US
Hi, I understand how to use group by, but how can group-by used as an expressions?
thank you for your time.
 
Example:
select orderno,sum(price)
from orderrow
where orderdate > date('2002-01-01')
group by sum(price)
having sum(price) > 1000
order by orderno;

This means:
get me all ordernumbers and sum of price in orderrow table with the limit that orderdate should be after 1 jan and the price sum is more than 1000. Sort on ordernumber.

Group by is used together with aggregate functions (sum, count, max, min, avg...).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top