I am having a problem with this SQL.
select cast(emp_first_name as char(12)) as 'First Name', cast (emp_last_name as char(12)) as 'Last Name', emp_salary as 'Salary', emp_gender as 'Gender', emp_dpt_number as 'Dept Number' from employee
where emp_dpt_number = '3' or emp_gender = 'M' and emp_salary > 40000
Why is it returning results with less than 40000. The problem reads salary more that 40000 and gender male or dept number 3.
Thanks for any help
SQL Question
Page 1 of 12 Replies - 811 Views - Last Post: 29 October 2007 - 01:56 PM
Replies To: SQL Question
#2
Re: SQL Question
Posted 29 October 2007 - 01:34 PM
I don't see anything marking which table you're selecting the data from, could that be part of the issue?
Also, try this:
Also, try this:
where (empty_dtp_number = '3' or emp_gender = 'M') and emp_salary > 40000
#3
Re: SQL Question
Posted 29 October 2007 - 01:56 PM
Thanks for the help it was the ( )'s around the OR. Once again thanks for the help and quick reply
James Bond C++ Spy
James Bond C++ Spy
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|