Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
michael.conner10@gte.net
Starting Member
2 Posts |
Posted - 2006-11-16 : 14:04:45
|
...For Oracles DECODE function? I am trying to get a conditional output RETURNed to the Grid output and have not found it in SQL Help. Help!!!Here is Oracles example: Select Distinct City, DECODE (City, 'Cincinnati', 'Queen City', 'New York', 'Big Apple', 'Chicago', 'City of Broad Shoulders', City) AS Nickname From Cities;  |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-11-16 : 14:09:08
|
| [code]Select Distinct City, NicknameFrom Cities AS C JOIN ( SELECT [City] = 'Cincinnati', [Nickname] = 'Queen City' UNION ALL 'New York', 'Big Apple' UNION ALL SELECT 'Chicago', 'City of Broad Shoulders' ) AS D ON C.City = D.City[/code]but I would want these sort of lookups in a table of their own in the first place, and provide the End User with a maintenance tool so they can add new ones.You could also use a CASE statement in the SELECT clause:[code]Select Distinct City, [Nickname] = CASE City WHEN 'Cincinnati' THEN 'Queen City' WHEN 'New York' THEN 'Big Apple' .... END[/code]Kristen |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-11-16 : 14:09:16
|
no it doesn't.you'll have to play with case expression.Go with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
michael.conner10@gte.net
Starting Member
2 Posts |
Posted - 2006-11-16 : 15:25:55
|
Thanks so much Kristen and Spirit1. I truly appreciate your assistance. Cordially, C. Michael Conner, PMPmichael.conner10@gte.net425.489.9014 (home)425.260.3838 (pcs) |
 |
|
|
|
|
|
|
|