Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating a view with a case
Message
From
04/12/2002 10:33:10
 
 
To
All
General information
Forum:
ASP.NET
Category:
Databases
Title:
Creating a view with a case
Miscellaneous
Thread ID:
00729439
Message ID:
00729439
Views:
42
hello all, I need help creating a view in SQL Server. The problem is that the Query Designer does not accept the case statement. Is there anyway possible that I can create the following view? Would there be a speed issue if I (could) create it on the fly and then drop it when I am done? Thanks for the help.
SELECT tblESCProblemLog.ProblemLogID, 
    SUM(CASE ProblemCodeID WHEN 33 THEN 1 ELSE 0 END) AS strName,
    SUM(CASE ProblemCodeID WHEN 34 THEN 1 ELSE 0 END) AS strLocation,
    SUM(CASE ProblemCodeID WHEN 35 THEN 1 ELSE 0 END) AS strPhysician,
    SUM(CASE ProblemCodeID WHEN 36 THEN 1 ELSE 0 END) AS strBirthDate, 
    SUM(CASE ProblemCodeID WHEN 37 THEN 1 ELSE 0 END) AS strSex, 
    SUM(CASE ProblemCodeID WHEN 32 THEN 1 ELSE 0 END) AS strClient, 
    SUM(CASE ProblemCodeID WHEN 31 THEN 1 ELSE 0 END) AS strMedex, 
    SUM(CASE ProblemCodeID WHEN 38 THEN 1 ELSE 0 END) AS strNoCharge, 
    SUM(CASE strMergedInvolved WHEN 'Y' THEN 1 ELSE 0 END) AS strMergedInvolved 
FROM tblescproblemlog 
	LEFT OUTER JOIN tblescproblemloguproblemcode ON 
		tblESCProblemLog.ProblemLogID = tblescproblemloguproblemcode.ProblemLogID 
GROUP BY tblESCProblemLog.ProblemLogID
Randy Belcher
AFG Industries, Inc.
Next
Reply
Map
View

Click here to load this message in the networking platform