Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old October 8th, 2008, 08:09 PM
didajosh's Avatar
Newbie
 
Join Date: Aug 2008
Posts: 20
Default How to put IF conditions on COLUMN NAMES...

Hi,



My table is like

A/C_NO----BUD_00------YTD_00------BUD_01-----YTD_01-----BUD_02-----YTD_02
014-----------1000------------10---------------1000---------20------------1100-----------30

the result I want is something like:


A/C_NO----BUD_01------EXP_01
014-----------1000------------10

BUD shows the budget
EXP_01, is the EXPENSE in period 01,
which is calculate as the period specific expense and calculated as
(YTD_01) - (YTD_00).

User selects, which period, he wants the information for, like 00,01,02

How do I do this….I am clueless…. :-o

-dipali
Reply
  #2  
Old October 8th, 2008, 09:09 PM
debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 6,870
Default

in which part you want to use IF condition ?
Reply
  #3  
Old October 18th, 2008, 03:06 PM
amitpatel66's Avatar
Moderator
 
Join Date: Mar 2007
Location: India
Age: 24
Posts: 2,028
Default

I think from the information that you have provided you are looking at using a WHERE condition in your query.

SOmething like SELECT col1,col2,col3 FROM table_name WHERE period = '00' (This can be a input parameter and can user pass in the value 00,01 or 02)
Reply
  #4  
Old November 20th, 2008, 09:39 PM
didajosh's Avatar
Newbie
 
Join Date: Aug 2008
Posts: 20
Default

Thank you all, this issue had been resolved.
Reply
  #5  
Old November 21st, 2008, 07:16 AM
Member
 
Join Date: Oct 2008
Location: Home
Age: 97
Posts: 120
Default

Hi,

Explaining your solution could help others.

Pilgrim.
Reply
  #6  
Old November 21st, 2008, 03:30 PM
didajosh's Avatar
Newbie
 
Join Date: Aug 2008
Posts: 20
Default

I used CASE here.
e.g
select column names,
(CASE
when (:PERIOD) = ('01')
THEN ((YTD_01) - (YTD_00))

WHEN (:PERIOD) = ('02')
THEN ((YTD_02) - (YTD_01))

END)
as EXPENSE


Regards,
Dipali
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles