General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 17th, 2004, 09:33 AM
rohit_reborn rohit_reborn is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 3 rohit_reborn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
conditonal selection of 'AND' and 'SELECT'

I am working on Oracle reports . One of the parameters that a User
inputs is
'report_type'. Now, is there a way to do the following within a SQL
query with no use of procedures or functions.

select blaa from foo where

something = something
// if report_type='some_data' then
and somethingelse = something else
//else do nothing


Also, IS there a way of doing something like the following

// if report_type='some_data' then

select blaa from foo where
something = something
// if report_type='some_data' then
and somethingelse = something else
//else do nothing

else
select blass1 from foo where
something = something
// if report_type='some_data' then
and somethingelse = something else
//else do nothing

ALSO,

how would one achieve the following

select bla from ( if report_type=something
then
select decode(bla,..)
else
select decode(boo,..)
.......... rest is the same for both the selects

Reply With Quote
  #2  
Old April 30th, 2004, 02:18 PM
michlmann michlmann is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 56 michlmann User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
1. see my answer on your second posting
2.
Quote:
Originally Posted by rohit_reborn
how would one achieve the following

select bla from ( if report_type=something
then
select decode(bla,..)
else
select decode(boo,..)
.......... rest is the same for both the selects

select decode(report_type, 'something', decode(bla...), decode(boo...)) from table...

3.

Quote:
Also, IS there a way of doing something like the following

// if report_type='some_data' then

select blaa from foo where
something = something
// if report_type='some_data' then
and somethingelse = something else
//else do nothing

else
select blass1 from foo where
something = something
// if report_type='some_data' then
and somethingelse = something else
//else do nothing
This doesn't make much sense. The second select (select blass1) would always run into your else-branch and therefore would "do" (i'd prefer return) nothing

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > conditonal selection of 'AND' and 'SELECT'


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT