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

Select 1

Status
Not open for further replies.

mayu03

Programmer
Oct 3, 2003
91
US
I have the following code in my sp where I am passing the param:
select count(*) as Voided from Table1 where groupNumber=@GroupID and status='V'
select count(*) as Active from Table1 where groupNumber=@GroupID and status='A'

I wanted to display this way when the sp exec:
Voided x
Active y

Is it possible to do this?
 
select 'Voided ' + CONVERT(Char,count(*)) from Table1 where groupNumber=@GroupID and status='V'
select 'Active ' + CONVERT(Char,count(*)) from Table1 where groupNumber=@GroupID and status='A'



Thanks

J. Kusch
 
AVOIDS USING SUBQUERIES

Code:
SELECT CASE WHEN STATUS = 'V' THEN 'VOIDED' ELSE 'ACTIVE' END AS TYPE,
       COUNT(*)
FROM TABLE1
WHERE GROUPNUMBER = @GROUPID
GROUP
BY CASE WHEN STATUS = 'V' THEN 'VOIDED' ELSE 'ACTIVE' END
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top