Link to home
Start Free TrialLog in
Avatar of ES-Components
ES-ComponentsFlag for United States of America

asked on

How Do I Get Select Statement To Return Correct Results?

See select statement below. I am not getting the expected results. We need:
Requirements:
1. Must enter the Date Range, you enter PrLine Only - Get results
2. Must enter the Date range, you enter Desc only - Get Results
3. Must enter the Date Range, you enter PrLine and Desc  - Get Results

Can the requirements be met with one select Statement?

SELECT *
FROM BidsAndNotesFINAL
WHERE (BidDetailFinal_PrLine LIKE '%PriceLine%') OR (BidDetailFinal_Desc LIKE '%Desc%') AND (BidDetailFinal_OrdDate BETWEEN #varStartRange# AND #varEndRange#)
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Try Parenthesizing the first two expressions -- open parenthesis to the right of "WHERE" and close parenthesis to the left of "AND":
SELECT *
FROM BidsAndNotesFINAL
WHERE ( (BidDetailFinal_PrLine LIKE '%PriceLine%') OR (BidDetailFinal_Desc LIKE '%Desc%') ) AND (BidDetailFinal_OrdDate BETWEEN #varStartRange# AND #varEndRange#)
Avatar of ES-Components

ASKER

Your suggestion did not work. If I enter just the PrLine and Date Range I do not get the resuslts.

In your suggestion, if I enter PrLine and Desc and Date range it works.

I am beginning to think that I will need three separate query statements. I am not sure if I can do what we need in just one statement.
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
tHANK YOU....