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

Need help with Query result display

Status
Not open for further replies.

sonname

Programmer
May 18, 2001
115
US
I have a query that produces the following results.

class, division, count, status
86 50 200 Approved
86 50 67 Not Approved

Is there a way I can get it so that it displays in the following manner?

class, division, Approved, Not Approved
86, 50, 200, 67

Basically I want to combine the class and division and make the status as part of the column headings.
 
What have you tried?

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Select Class,Division Sum(iif(Status="Approved",1,0)) as Approved, Sum(iif(Status="Not Approved",1,0)) as NotApproved
From QueryName
 
Sorry gave you access Syntex

try

Select Class,Division Sum(Case when Status='Approved' then 1 else 0 end ) as Approved, Sum(Case when Status='not Approved' then 1 else 0 end ) as NotApproved
From QueryName
 
You miss GROUP BY
Code:
Select Class,
       Division,
       Sum(Case when Status='Approved'
                then 1
                else 0 end ) as Approved,
       Sum(Case when Status='Approved'
                then 0
                else 1 end ) as NotApproved
From QueryName 
GROUP BY Class, Division

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
Microsoft MVP VFP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top