March 30, 2010 at 6:32 am
help me write below query:
a start will also help 🙂
if drverri.despmce = space
drverri.deinstn = dropera.deinstn and
drverri.deopnnr = dropera.deopnnr and
drverri.deregjr = dropera.deregjr and
drverri.devawpn = dropera.devawpn and
drverri.deverrn = dropera.deverrn and
dropera.deinstn = drspect.deinstn and
dropera.despece = drspect.desptce and
drverri.dedaver between drspect.dedatin and drspect.dedaten
spmeuitv = drspect.despmce
else
spmeuitv = drverri.despmce
March 30, 2010 at 6:41 am
not enough info, khushbu ; the pseudo code you posted....is that an UPDATE? a SELECT? what is the question?
it almost looks like an attempt at an UPDATE to me, but I can't tell;
I can infer that there are three tables in question: drverri dropera and drspect
but beyond that, i'n not sure what you wanted to accomplish.
khushbu (3/30/2010)
help me write below query:a start will also help 🙂
if drverri.despmce = space
drverri.deinstn = dropera.deinstn and
drverri.deopnnr = dropera.deopnnr and
drverri.deregjr = dropera.deregjr and
drverri.devawpn = dropera.devawpn and
drverri.deverrn = dropera.deverrn and
dropera.deinstn = drspect.deinstn and
dropera.despece = drspect.desptce and
drverri.dedaver between drspect.dedatin and drspect.dedaten
? spmeuitv = drspect.despmce
else
? spmeuitv = drverri.despmce
Lowell
March 30, 2010 at 6:42 am
it's not entirely clear what you want;
if it is a query with a where clasue the format is
select * from table
where <where clause>
March 30, 2010 at 6:43 am
would probably candidate for update.. but since it has to deal with billions records I was just thinking of doing it with select with some other fields being populated.
March 30, 2010 at 6:54 am
if U want to use if statement in the query go for case...
Case
when ( drverri.despmce = space
drverri.deinstn = dropera.deinstn and
drverri.deopnnr = dropera.deopnnr and
drverri.deregjr = dropera.deregjr and
drverri.devawpn = dropera.devawpn and
drverri.deverrn = dropera.deverrn and
dropera.deinstn = drspect.deinstn and
dropera.despece = drspect.desptce and
drverri.dedaver between drspect.dedatin and drspect.dedaten )
Then
spmeuitv = drspect.despmce
ELSE
spmeuitv = drverri.despmce
END
AS SPmeuitvValue
Use it in either select or Update
March 30, 2010 at 7:00 am
this is syntactically incorrect, whether a select or an update....paste it in SSMS and see for your self.
Sasidhar Pulivarthi (3/30/2010)
if U want to use if statement in the query go for case...Case
when ( drverri.despmce = space
drverri.deinstn = dropera.deinstn and
drverri.deopnnr = dropera.deopnnr and
drverri.deregjr = dropera.deregjr and
drverri.devawpn = dropera.devawpn and
drverri.deverrn = dropera.deverrn and
dropera.deinstn = drspect.deinstn and
dropera.despece = drspect.desptce and
drverri.dedaver between drspect.dedatin and drspect.dedaten )
Then
spmeuitv = drspect.despmce
ELSE
spmeuitv = drverri.despmce
END
AS SPmeuitvValue
Use it in either select or Update
Lowell
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply