Solved

Operator '<=' facing multi-value data

Posted on 2009-03-30
3
193 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
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.​
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now