Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT SQL Question

Status
Not open for further replies.

TSO456

Technical User
Jul 23, 2001
57
US
Hello,

I have the following table. How can I select the clients that have 100 employees and are in prodcut X or Prodcut Y

Client # EMPLOYEES Prodcut

A 100 X
B 200 Y
C 100 X
D 50 Y
E 25 X

Thank You

 
SELECT client FROM client_table
WHERE num_employees = 100 AND
prodcut in ('X','Y')
 
by "in" you mean that prodCut is either x or y -- is that right? And when you say have 100 employees, do you mean exactly 100 or 100 or more?

If you mean exactly 100, then you can say:

SELECT client FROM client_table
WHERE num_employees = 100 AND
prodcut = 'X' OR prodCut = 'Y'

and if you mean 100 or more, then you can ask:

SELECT client FROM client_table
WHERE num_employees >= 100 AND
prodcut = 'X' OR prodCut = 'Y'
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top