Solved

Operator '<=' facing multi-value data

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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.​
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

23 Experts available now in Live!

Get 1:1 Help Now