Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good day Guys

I have a table
with two columns

order and status

order can contain the same order number multiple times
status can contain 1 to 9

I want to select all the orders which have a status of 8 but not a status of 9

Any assistance would be appreciated

Kind regards
Posted
Updated 16-Feb-15 20:34pm
v2
Comments
Tomas Takac 17-Feb-15 2:27am    
Not clear. Please show your input data.
Rajesh waran 17-Feb-15 2:32am    
Not clear. Do you mean two Columns? If you have two columns(order and Status), then try this query "Select order,status from Table_Name where status=8" or provide more info about table records and Required output.
mrDivan 17-Feb-15 2:35am    
Sorry I have edited it I mean columns I cannot use = because it will return everything I need to now which ones have a status 8 but not a 9 status

Kind regards
phil.o 17-Feb-15 2:43am    
What did you try?

Try like this,As i told you in my comments,
If you need records having status=8:
SQL
select order,status from Table_Name where status=8


Or Records from 1 to 8 :
SQL
select order,status from Table_Name where status<=8
 
Share this answer
 
Sorry I seem to have difficulty explaining myself English is not my first language I have to return o1 and o3 as o2 has a status of 9


Quote:
ColOrder Colstatus
o1 1
o1 2
o1 3
o1 4
o1 5
o1 6
o1 7
o1 8
o2 1
o2 2
o2 3
o2 4
o2 5
o2 6
o2 7
o2 8
o2 9
o3 1
o3 2
o3 3
o3 4
o3 5
o3 6
o3 7
o3 8



Kind regards
 
Share this answer
 
Comments
Rajesh waran 17-Feb-15 3:02am    
Don't post your Question as Comments.Just edit you question.
Rajesh waran 17-Feb-15 3:03am    
Do you need all data without status=9
mrDivan 17-Feb-15 3:20am    
Hi no only the order numbers which don't have a status 9 so O1 and o3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900