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

Unique - or sort of

Status
Not open for further replies.

SQLScholar

Programmer
Aug 21, 2002
2,127
GB
Hey all,

I have a rather complex table. There is a reference number which is unique and a policy number which is not.

Is there a way that in an SQL query if there is more then one policy to add up the rest of the fields i.e

If i had

ref pol Cost
1 100 20
2 100 30
3 120 10

would become

ref pol Cost
1 100 50
3 120 10

Thanks all.

Dan

----------------------------------------
There are 2 types of computer, the prototype and the obsolete!!
 
Something like this ?
SELECT FIRST(ref) AS Ref1, pol, SUM(Cost) as TotalCost
FROM yourTable
GROUP BY pol
;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top