You are here: Re: Help with case when « MsSQL Server « IT news, forums, messages
Re: Help with case when

Posted by Erland Sommarskog on 09/30/36 11:54

dwerden (dwerden@purdue.edu) writes:
> I need help.
> This is the code I currently have and need to change:
> p.code as "Code",
> p.detail_type as "Detail Type",
>
> p.code shows diagnostic code numbers and billing procedure numbers
> while p.detail_type indicate which is which. Diagnostic code numbers
> are designated as '-2' (minus 2) in the 'detail_type' and procedure
> codes are designated as '-4' (minus 4) in the 'detail_type.' The query
> I am using now (see below) gives me duplicate appt dates to show both
> the diagnostic code and procedure code. I need to clean this up a bit.
>
>
> What I want this to do is find a statement that will separate the codes
> into diagnosis numbers and procedure numbers and place these numbers in
> different columns in the ad hoc report that is generated.
>
> I would like something to the effect of:
> If p.detail_type = -2 then place the code number in a column known as
> "Code"
> If p.detail_type - -4 then place the code number in a column known as
> "Procedure"
>
> Any ideas on how to write this?

CASE p.detail_type WHEN -2 THEN p.code END AS Code,
CASE p.detail_type WHEN -4 THEN p.code END AS Procedure,


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация