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
 General SQL Server Forums
 New to SQL Server Programming
 adding more to a query

Author  Topic 

JJ297
Aged Yak Warrior

940 Posts

Posted - 2012-02-29 : 13:02:05
How do I add these statements to this query:

( Datediff(DAY, filedate, Getdate()) > 300 )
( Datediff(DAY, filedate, Getdate()) > 350 )
( Datediff(DAY, filedate, Getdate()) > 400 )



if @doc in ('V01')
Begin
Select DOC,
Reg,
FO,
CLMS,


Age = Datediff(day,max(filedate), getdate()),
FileDate = max(FileDate),
o.mailingaddressstate as DDS,
o.ddsofficecode as DDSCode,
Min(ddsrcpt) AS DDSReceipt,
DDSAge = Datediff(day,min(ddsrcpt), getdate()),
Title = case when min(p.Title) <> max(p.Title) then 'Concurr' else min(p.Title) end
From
(select *, row_number() over (Partition by ddsrcpt order by ddsrcpt) as rownum
from pendingdds) p
join offices.dbo.doorsinfo o
on o.officecode = p.fo
where doc in ('V01', 'S67', 'S41', 'S66')
AND ( Datediff(DAY, filedate, Getdate()) > 250 )

Group By FO, Reg, DOC, CLMS, o.mailingaddressstate, o.ddsofficecode
order by p.fo, age , DDSReceipt desc
End


I have radio buttons on the client side page. The page comes in as a default as 250 pending. If you select 300 I want that info to appear.

X002548
Not Just a Number

15586 Posts

Posted - 2012-02-29 : 13:08:10
How does that make sense?

If this is true

( Datediff(DAY, filedate, Getdate()) > 300 )

Then these are always True

( Datediff(DAY, filedate, Getdate()) > 350 )
( Datediff(DAY, filedate, Getdate()) > 400 )


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2012-02-29 : 13:17:19
It doesn't. I will have to make four stored procedures to get the items I want out unless you know of another way I could approach this.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-02-29 : 13:19:59
Unless you didn't post the correct code, then yes, what I posted is TRUE when they are OR

If they are AND, then the last one must be TRUE

but, whatever

AND ( Datediff(DAY, filedate, Getdate()) > 300 )
AND ( Datediff(DAY, filedate, Getdate()) > 350 )
AND ( Datediff(DAY, filedate, Getdate()) > 400 )

Is that what you are looking for?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2012-02-29 : 13:23:31
I posted the correct code I just have to figure out how I want to call each one separatly
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-02-29 : 14:07:51
do you mean passing information from the Front end?

I must be missing something



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2012-02-29 : 14:31:02
Yes I will have to pass from that end instead.

I got it to work. I am just going to use different pages and different stored procedures. It's tedious but it works.
Go to Top of Page
   

- Advertisement -