Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 18th, 2005, 08:30 AM
Registered User
 
Join Date: Oct 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to rajkumar007
Default Join

Hi,

  I ve two fiedls like
ex:
ename, designation.
george A ---->(record)
paul M ---->(record)
I n designation i ve mentioned A (means Accountant) M (means Manager)
I want to dislay the result as

ex:
ename designation
george Account
paul Manager

Pl help me..

 
Old October 18th, 2005, 08:34 AM
Authorized User
 
Join Date: Sep 2005
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Default

select name, case designation when 'A' then 'Accountant' else 'Manager' end as designation from table

Don't you have a lookup table for this???

http://sqlservercode.blogspot.com/
 
Old October 20th, 2005, 01:28 PM
Authorized User
 
Join Date: Oct 2005
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can use a CASE statement for this if you don't have a table that contains what they mean:

SELECT ename, CASE Designation WHEN 'A' THEN 'Accountant' WHEN 'M' THEN 'Manager' ELSE 'Unknown' END AS Designation
FROM YourTable

SQL Server Helper
http://www.sql-server-helper.com
 
Old October 20th, 2005, 03:20 PM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can use a Case statement but you "should" use a lookup table as previously described. It's a better habit to get into.






Similar Threads
Thread Thread Starter Forum Replies Last Post
join dhara_adh SQL Server 2000 2 January 2nd, 2007 12:39 AM
Join or not join madhukp SQL Server 2000 3 February 2nd, 2005 01:11 AM
More than one join jaywhy13 Classic ASP Basics 2 January 31st, 2005 11:38 PM
INNER JOIN msmagied Classic ASP Databases 3 August 29th, 2004 12:28 PM
Oracle 8i inner join and left join problem puteri_84 Oracle 2 August 19th, 2004 07:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.