Hi Experts,
Need your help w/ a simple query.
This is for MS SQL 2005
Here's my SQL:
SELECT SUBSTRING(FullName,1,4) Name, Section,
SUM(Cost) 'Cost'
FROM tbl01
WHERE section = '1A1'
GROUP BY SUBSTRING(FullName,1,4), Section, Cost
Here's the recordset:
Name Section Cost
------- ------- -------
John 1A1 94
John 1A1 250
John 1A1 244756
Mark 1A1 24
Mark 1A1 562
Mark 1A1 14541
Mark 1A1 85796
Henry 1A1 8
Henry 1A1 44
Henry 1A1 125
Henry 1A1 2116
Henry 1A1 2270
Henry 1A1 4847
Henry 1A1 12234
Henry 1A1 244756
I was hoping to get it down to three records:
Name Section Cost
------- ------- -------
John 1A1 ......
Mark 1A1 ......
Henry 1A1 ......
Any idea how to fix the sql?
TIA!
Start Free Trial