Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language 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 March 28th, 2004, 03:15 PM
Authorized User
 
Join Date: Nov 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default adding fixed dummy column

Hi All,
2 questions :
1.i want to add a column(to the result pane) with the value "EUR" to all rows returnd by a SELECT clause (for example "select * from invoices").how do i do that ?
2.one of the colums supports one of the 3 values - 1,2,3
if the value is 1 - i want the column value in the result pane to be "male"
if the value is 2 - i want the column value in the result pane to be "female"

if the value is 3 - i want the column value in the result pane to be "other"

is there any way to do this mapping inside the SQL SELECT caluse ?

Thank you very much





Yuval Kronenfeld
Web Developer
__________________
Yuval Kronenfeld
Israel
 
Old March 28th, 2004, 06:07 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Answers given below.

1. select *, "EUR" from invoices
        This adds a new column in the display pane as EUR for all resulted rows from the invoices table.

2. It should look something like the following.

select "************"=case
        when ************_COLUMN_NAME=1 then "Male"
        when ************_COLUMN_NAME=2 then "Female"
        else "Other"
    end

Hope that helps.

Cheers,

-Vijay G
 
Old March 28th, 2004, 06:09 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Oops, I missed the from clause in my previous post.

select "************"=case
        when ************_COLUMN_NAME=1 then "Male"
        when ************_COLUMN_NAME=2 then "Female"
        else "Other"
    end
    FROM TABLE_NAME

-Vijay G
 
Old March 28th, 2004, 06:51 PM
Authorized User
 
Join Date: Nov 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you
working perfect !

Yuval

Yuval Kronenfeld
Web Developer
 
Old March 29th, 2004, 05:37 AM
Authorized User
 
Join Date: Nov 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you !



Yuval Kronenfeld
Web Developer





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dummy AS400 butter Javascript How-To 1 October 28th, 2008 02:08 AM
adding column numbers decren Javascript How-To 2 May 5th, 2007 07:48 AM
dummy lua install Brad C BOOK Beginning Lua Programming ISBN: 978-0-470-06917-2 2 March 28th, 2007 11:36 AM
Adding up Column Values within a Datatable rit01 ASP.NET 2.0 Basics 1 May 31st, 2006 11:27 AM
Adding Checkbox column in datagrid anita ASP.NET 1.0 and 1.1 Basics 0 December 20th, 2004 07:16 AM





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