Solved

Operator '<=' facing multi-value data

Posted on 2009-03-30
3
197 Views
Last Modified: 2012-05-06
I have the following code:

select * from Request_History
where
      Stage_No <= (select Stage_No from Work_Flow where Role_ID='7')

The question is: this (select Stage_No from Work_Flow where Role_ID='7') sometimes return more than one value, then what operator other than the '<=' shall I use in this case?
0
Comment
Question by:alfardan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 38

Expert Comment

by:Jim P.
ID: 24025355
Try this:
select * 
from Request_History
where Stage_No IN (select Stage_No 
                   from Work_Flow 
                   where Role_ID='7')

Open in new window

0
 
LVL 35

Accepted Solution

by:
Terry Woods earned 250 total points
ID: 24025364
Or one of these, depending on the result you want when there's more than one row returned by the subquery:
select * from Request_History
where Stage_No <= (select min(Stage_No) from Work_Flow where Role_ID='7')
 
select * from Request_History
where Stage_No <= (select max(Stage_No) from Work_Flow where Role_ID='7')

Open in new window

0
 
LVL 25

Assisted Solution

by:lwadwell
lwadwell earned 250 total points
ID: 24025368
Hi alfardan,

perhaps you should do

lwadwell
select * from Request_History
where
      Stage_No <= (select max(Stage_No) from Work_Flow where Role_ID='7')

Open in new window

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Stored Proc - Rewrite 42 73
SQL Query help 3 25
Changing the Schema for all Tables in a Tables - MS SQL Server 2008 R2. 3 33
sql select total by week ending 3 26
Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question