Dunno if this will work for you but how about something like this: select id, sum(tempsum) temp, sum(pressum) pres, sum(saturationsum) saturation from ( select id, sum(value) tempsum, sum(0) pressum, sum(0) saturationsum from table where code group by id union select id, sum(0) tempsum, sum(value) pressum, sum(0) saturationsum from table where code group by id union select id, sum(0) tempsum, sum(0) pressum, sum(value) saturationsum from table where code group by id ) group by id Mark Derricutt <[EMAIL PROTECTED]> on 11/12/98 00:36:32 Please respond to [EMAIL PROTECTED] To: Multiple recipients of list delphi <[EMAIL PROTECTED]> cc: (bcc: Peter Jones/Logistics&Information Technology/Christchurch/Foodstuffs) Subject: [DUG]: SQL Problem [This message has also been posted.] I have a table looking like this: ID | Code | Value -----+--------+------- A | T | V1 A | P | V2 A | S | V3 B | T | V4 B | P | V5 B | S | V6 And I want to turn it into a table like: ID | Temp | Pres | Saturation -----+--------+--------+------------ A | V1 | V2 | V3 B | V4 | V5 | V6 Is it possible to do this via an SQL Query at all??? Mark --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz