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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grouping by a selected fiels

Status
Not open for further replies.

Jhankins

Programmer
Jun 17, 2003
46
AU
I have the following data:

id date amount chequeid transid
1 22/05/04 10 1 001
1 22/05/04 15 1 002
1 22/05/04 30 2 003
1 23/05/04 40 3 004

I want to return 3 columns i.e. group all the chequeid that are the same so it will return then following

id date amount chequeid transid
1 22/05/04 25 1 002
1 22/05/04 30 2 003
1 23/05/04 40 3 004

Any idea's??

Thanks
 
Is this any good?

select id, date, sum(amount), chequeid, max(transid)
from tblCheck
group by id, date, chequeid
 
Code:
select id
     , convert(char(10),date,3) as thedate
     , sum(amount)
     , chequeid
     , max(transid)
  from tblCheck
group 
    by id
     , convert(char(10),date,3)
     , chequeid

rudy
SQL Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top