MS SQL 2005- Store Procedure

Romacali
Romacali used Ask the Experts™
on
Hi all,
how can I write a procedure to display a field LanguageOther when Laguage = 99?

I will read this on my lable in the cs page.
thanks,
here is what I have so far:

BEGIN
 
     select c.FileNo, c.Designation, c.Fdate, c.Assent, c.Language as LanguageC, 
           case    when (c.Ethnicity  = 1) then 'African American'
	when (c.Ethnicity  = 2) then 'Asian'
	when (c.Ethnicity  = 3) then 'Caucasian'
	when (c.Ethnicity  = 4) then 'Hispanic'
	when (c.Ethnicity  = 99) then 'Other'
 
end  as [EthnicityC], 
c.EthnicityOther as EthnicityOtherC, -- I need this to display when (c.Ethnicity  = 99)
from tbl_Child c

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
AneeshDatabase Consultant
Top Expert 2009

Commented:
not sue what you are looking for,

BEGIN
 
     select c.FileNo, c.Designation, c.Fdate, c.Assent, c.Language as LanguageC,
           case    when (c.Ethnicity  = 1) then 'African American'
      when (c.Ethnicity  = 2) then 'Asian'
      when (c.Ethnicity  = 3) then 'Caucasian'
      when (c.Ethnicity  = 4) then 'Hispanic'
      when (c.Ethnicity  = 99) then 'Other'
 
end  as [EthnicityC],
CASE WHEN c.Ethnicity  = 99 THEN c.EthnicityOther ELSE ''  as EthnicityOtherC, -- I need this to display when (c.Ethnicity  = 99)
from tbl_Child c
Case when  c.Ethnicity > 4 then Null Else c.EthnicityOther End as EthnicityOtherC

Commented:
Try something like this:
BEGIN
 
     select c.FileNo, c.Designation, c.Fdate, c.Assent, c.Language as LanguageC, 
           case    when (c.Ethnicity  = 1) then 'African American'
        when (c.Ethnicity  = 2) then 'Asian'
        when (c.Ethnicity  = 3) then 'Caucasian'
        when (c.Ethnicity  = 4) then 'Hispanic'
        when (c.Ethnicity  = 99) then 'Other'
 
end  as [EthnicityC], 
case when (c.Ethnicity=99) then c.EthnicityOther else '' end as EthnicityOtherC, -- I need this to display when (c.Ethnicity  = 99)
from tbl_Child c

Open in new window

Acronis in Gartner 2019 MQ for datacenter backup

It is an honor to be featured in Gartner 2019 Magic Quadrant for Datacenter Backup and Recovery Solutions. Gartner’s MQ sets a high standard and earning a place on their grid is a great affirmation that Acronis is delivering on our mission to protect all data, apps, and systems.

Author

Commented:
Is there a way to combine the two fields into one comma delimited column?

Mohed SharfiVice CEO

Commented:
Hi
Please try this
thanks
BEGIN
 
     select c.FileNo, c.Designation, c.Fdate, c.Assent, c.Language as LanguageC, 
           CASE c.Ethnicity     when 1 then 'African American'
        when 2 then 'Asian'
        when  3 then 'Caucasian'
        when  4 then 'Hispanic'
        when  99 then 'Other'
 
end  as [EthnicityC]
from tbl_Child c

Open in new window

Author

Commented:
this is the way I had.. I still need the EthnicityOther .. I would like to display field Ethnicity and EthnicityOther on the same column
Commented:
Hmm. That's even simpler i think.

Try this:
BEGIN
 
     select c.FileNo, c.Designation, c.Fdate, c.Assent, c.Language as LanguageC, 
           case    when (c.Ethnicity  = 1) then 'African American'
        when (c.Ethnicity  = 2) then 'Asian'
        when (c.Ethnicity  = 3) then 'Caucasian'
        when (c.Ethnicity  = 4) then 'Hispanic'
        when (c.Ethnicity  = 99) then 'Other: ' + c.EthnicityOther
 
end  as [EthnicityC], 
from tbl_Child c

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial