santoshmotwani
asked on
SQL Query
Hi,
I have a following table
consumerno billdate billamount
54321 01/01/2011 100
54322 15/01/2011 50
54321 02/02/2011 175
54322 03/02/2011 100
i want a query that will give me bill amount for a consumerno with latest bill date.
i,.e.
consumerno billdate billamount
54321 02/02/2011 175
54322 03/02/2011 100
Please Help
I have a following table
consumerno billdate billamount
54321 01/01/2011 100
54322 15/01/2011 50
54321 02/02/2011 175
54322 03/02/2011 100
i want a query that will give me bill amount for a consumerno with latest bill date.
i,.e.
consumerno billdate billamount
54321 02/02/2011 175
54322 03/02/2011 100
Please Help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thnx !!!
>what if i want total billamount ?
In that case, for the exact 3 columns required, a simply group by would suffice.
select consumerno, max(billdate) billdate, sum(billamount) totalamount
from tbl
group by consumerno
In that case, for the exact 3 columns required, a simply group by would suffice.
select consumerno, max(billdate) billdate, sum(billamount) totalamount
from tbl
group by consumerno
ASKER
what if i want total billamount ?
Thnx for your help