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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 select a, b, case when exp then c, d try if u can

Author  Topic 

nssjari
Starting Member

46 Posts

Posted - 2005-07-06 : 07:25:11
Hi friends ...

---
My existing query is as follows
---

select

csd1.csd_orig + csd1.csd_subj + csd1.csd_type + csd1.csd_numb + csd1.csd_revi, csd1.csd_issu, csd1.csd_altr,
tra1.tra_trno,
csd2.csd_orig + csd2.csd_subj + csd2.csd_type + csd2.csd_numb + csd2.csd_revi, csd2.csd_issu, csd2.csd_altr,
trd1.trd_trno, trd1.trd_recd,
apr1.apr_docu, apr1.apr_reqd, apr1.apr_stat,
tra2.tra_trno,
csd3.csd_orig + csd3.csd_subj + csd3.csd_type + csd3.csd_numb + csd3.csd_revi, csd3.csd_issu, csd3.csd_altr,
trd2.trd_trno, trd2.trd_recd

from

e0437csd csd1, e0437tra tra1, e0437csd csd2, e0437trd trd1, e0437apr apr1, e0437tra tra2, e0437csd csd3, e0437trd trd2

where

csd1.csd_orig + csd1.csd_subj + csd1.csd_type + csd1.csd_numb + csd1.csd_revi like '%SUBJECTCODE%' and
csd1.csd_ownr = 'BESIX' and
csd1.csd_aclas = 'CLASSCODE / TYPECODE' and

tra1.tra_drgn = csd1.csd_orig + csd1.csd_subj + csd1.csd_type + csd1.csd_numb + csd1.csd_revi and
tra1.tra_copy = 1 and
tra1.tra_appr = True and
tra1.tra_part = 'PARSO' and
tra1.tra_type = 'A' and

csd2.csd_orig + csd2.csd_subj + csd2.csd_type + csd2.csd_numb + csd2.csd_revi = tra1.tra_trno and
csd2.csd_ownr = 'BESIX' and
csd2.csd_aclas = 'T' and

trd1.trd_trno = csd2.csd_orig + csd2.csd_subj + csd2.csd_type + csd2.csd_numb + csd2.csd_revi and
trd1.trd_part = 'PARSO' and
trd1.trd_type = 'A' and
trd1.trd_cc = '0' and

apr1.apr_docu = csd1.csd_orig + csd1.csd_subj + csd1.csd_type + csd1.csd_numb + csd1.csd_revi and
apr1.apr_part = 'PARSO' and
apr1.apr_type = 'A' and

tra2.tra_drgn = csd1.csd_orig + csd1.csd_subj + csd1.csd_type + csd1.csd_numb + csd1.csd_revi and
tra2.tra_copy = 1 and
tra2.tra_appr = False and
tra2.tra_part = 'BESIX' and
tra2.tra_type = 'I' and

csd3.csd_orig + csd3.csd_subj + csd3.csd_type + csd3.csd_numb + csd3.csd_revi = tra2.tra_trno and
csd3.csd_ownr = 'PARSO' and
csd3.csd_aclas = 'T' and

trd2.trd_trno = csd3.csd_orig + csd3.csd_subj + csd3.csd_type + csd3.csd_numb + csd3.csd_revi and
trd2.trd_part = 'BESIX' and
trd2.trd_type = 'I' and
trd2.trd_cc = '0'

order by

csd1.csd_orig + csd1.csd_subj + csd1.csd_type + csd1.csd_numb + csd1.csd_revi

---
Now what i want is as follows
---

if "apr1.apr_stat" is null it must not select the rest of it in the select statement and hence no condition check in the where clause after tra2.blablabla onwards ... else

if "apr1.apr_stat" is not null it must execute the whole query ...
as it is as of now ...

since this "apr1.apr_stat" checks for incase a document is replied or not ... if replied it has give me related details and if not it has to select the availble details atleast of those documents ...

---
I know its difficult to get it that easily ...
But if u want to have more clrification please do reply to it ...asap
Its urgent please ... Thanks for Co-op ...

Jari
Computer Engg

nssjari
Starting Member

46 Posts

Posted - 2005-07-06 : 07:44:54
Is this query going to output you only 1 record?
Irfan.

Jari
Computer Engg
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-06 : 07:48:22
Not sure what you are asking for
Can you provide some sample data with expected result?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

nssjari
Starting Member

46 Posts

Posted - 2005-07-06 : 07:50:23
No it results all the records that are replied ... so far ...
But does not give me records that are not replied ...


Jari
Computer Engg
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2005-07-06 : 09:40:02
kill me.
i cant read that. i think it is time to switch from decaf to Heroin.

*need more coffee*
SELECT * FROM Users WHERE CLUE > 0
(0 row(s) affected)
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2005-07-06 : 10:26:06
quote:
Originally posted by DonAtWork

kill me.
i cant read that. i think it is time to switch from decaf to Heroin.

*need more coffee*
SELECT * FROM Users WHERE CLUE > 0
(0 row(s) affected)




ROFLMAO!!!

I think you misunderstand the symbol (though probably more accurate here )

Plus, caffiene is bad enough.

Corey

Co-worker on The Wizard of Oz "...those three midgets that came out and danced, the freaked me out when I was little. But they are ok now."
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2005-07-07 : 07:44:45
i do know what the *Snipe* is for.

But it just sort of
SELECT SUM(feelings) FROM this_post
for me.

*need more coffee*
SELECT * FROM Users WHERE CLUE > 0
(0 row(s) affected)
Go to Top of Page

mmarovic
Aged Yak Warrior

518 Posts

Posted - 2005-07-07 : 08:40:34
Thread creator is having conversation with himself!
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2005-07-07 : 08:51:13
quote:
Originally posted by DonAtWork

i do know what the *Snipe* is for.

But it just sort of
SELECT SUM(feelings) FROM this_post
for me.

*need more coffee*
SELECT * FROM Users WHERE CLUE > 0
(0 row(s) affected)



yeah... I was pretty sure you had the hang of it, but we can't have people volutarily *sniping* themselves We'll loose all of the good comments

I gave up on this guy... he never actually tries to help himself.

Corey

Co-worker on The Wizard of Oz "...those three midgets that came out and danced, the freaked me out when I was little. But they are ok now."
Go to Top of Page
   

- Advertisement -