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

A single result from one table

Status
Not open for further replies.

bhp

MIS
Joined
Jul 30, 2002
Messages
112
Location
US
Hi am sure this is simple can anyone show me how I can can a single row from each name in the following results:
Name Domain Open Open>7 Closed
Bjoern Diegmann IINFOSYS NULL 3 NULL
Bjoern Diegmann IINFOSYS 3 NULL NULL
Gareth Hoggins UK NULL NULL 5
Gareth Hoggins UK NULL 4 NULL
Gareth Hoggins UK 9 NULL NULL
i.e.
Name Domain Open Open>7 Closed
Bjoern Diegmann IINFOSYS 3 3 NULL
Gareth Hoggins UK 9 4 5
Any help greatly appreciated - James

 
Code:
SELECT Name,
       Domain,
       SUM(Open)     AS Open,
       SUM([Open>7]) AS [Open>7],
       SUM(Closed)   AS Closed
FROM YourTable
GROUP BY Name, Domain

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Fantastic new it would be easy was banging my head against wall on that one thank you kindly - James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top