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 2012 Forums
 Transact-SQL (2012)
 And/Or Operator Help

Author  Topic 

Jim637
Starting Member

5 Posts

Posted - 2013-05-29 : 21:50:29
Hi Guys,

Here is the part of SP where i am stuck.

-- Start


and (
(
(@Drawdate_c between DateAdd(MM,0-isnull(DAD.Max,60),getdate()) and DateAdd(MM,0-isnull(DAD.Min,0),getdate()))
)
OR (
(( @Drawdate_Ch between DateAdd(MM,0-isnull(DAD.Max,60),getdate()) and DateAdd(MM,0-isnull(DAD.Min,0),getdate())))
)

OR
(
( @Drawdate_A1 between DateAdd(MM,0-isnull(DAD.Max,60),getdate()) and DateAdd(MM,0-isnull(DAD.Min,0),getdate()))
and CONVERT(DECIMAL,isnull(@NumR_A1,-999.99)) between CONVERT(DECIMAL,isnull(DAD.MinV,-999.99)) and CONVERT(DECIMAL,isnull(DAD.MaxV,1000.0))
)
OR
(
( @Drawdate_L between DateAdd(MM,0-isnull(DAD.MaxD,60),getdate()) and DateAdd(MM,0-isnull(DAD.MinD,0),getdate())
and CONVERT(DECIMAL,isnull(@NumResule_L,-999.99)) between CONVERT(DECIMAL,isnull(DAD.Minv,-999.99)) and CONVERT(DECIMAL,isnull(DAD.MaxV,1000.0)))
)

OR (
@OrderD between DateAdd(MM,0-isnull(DAD.MaxD,60),getdate()) and DateAdd(MM,0-isnull(DAD.MinD,0),getdate())
)
)

-- End

I am not getting when i use And/Or Operator. May be I am missing '('.
Is someone take a look. I will provide more information if needed.

Thank You.

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2013-05-29 : 22:41:45
Maybe you can explain the problem...are you not getting expected results, or you just don't understand the logic that someone else wrote?
Or you need help writing the query?

It is always helpful to show us the table definitions, and some sample data so we can help you get the desired output
Go to Top of Page

Jim637
Starting Member

5 Posts

Posted - 2013-05-29 : 23:00:37
Russell Thank you for your reply. Here is the answer of your three questions.

1) are you not getting expected results = Yes I am not getting result that I want. I am sure there is something in And/Or areas.
2) or you just don't understand the logic that someone else wrote? = Here is my logic that's why i am stuck!
3) Or you need help writing the query? = Yes I need help with the query I paste in original Post.
4) It is always helpful to show us the table definitions, and some sample data so we can help you get the desired output = I agree. Like i said this is part of 600 Lines SP.

Thank You.
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2013-05-29 : 23:41:19
Ok, show us the table definition(s) (can right click and script table as create...) and a few sample rows.

Then tell us the expected output. And describe the situation in regular words.

One of us will help you sort it out, but we need that for a starting point.
Go to Top of Page

Jim637
Starting Member

5 Posts

Posted - 2013-05-30 : 00:03:50
Thanks Russell. I am 200% agree with you what you saying.
I am sorry I can't paste it 21 tables here with sample data!

I will figure it out and paste a solution for your reference...
Go to Top of Page
   

- Advertisement -