January 21, 2011 at 7:30 am
Hello,
Could someone please tell if there was a way to use group by with one field when there are multiple fields in the select statement and at the same time also sum one of the fields(not rhe group by one) ?
foe e.g. i need to achieve this:
-----------------------------------
Select BL_ID,
sum(D.FRT_USD) as FRT_USD,
TEU,
SAISAN_MONTH
from tablename
group by BL_ID
-----------------------------------
Thanks,
Paul
January 21, 2011 at 8:08 am
Depending on your required output
Select BL_ID,
sum(D.FRT_USD) as FRT_USD,
TEU,
SAISAN_MONTH
from tablename
group by BL_ID,TEU,SAISAN_MONTH
Or
Select BL_ID,
sum(D.FRT_USD) as FRT_USD,
MIN(TEU) as Min_TEU,
MIN(SAISAN_MONTH) AS Min_SAISAN_MONTH
from tablename
group by BL_ID
Or there might be the need of a subquery. It depends.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply