Very puzzled with results of SQL query

purceld2

Registered User.
Local time
Today, 16:20
Joined
Dec 4, 2008
Messages
79
Below I have attached the table the SQL and the results can somebody explain to me why row id 244, 400, 441 have been returned.

EMPLOYEESTATISTICSTABLEEmployeeIDNoSalaryBenefitsPosition107500015000 Manager1056500015000 Manager1526000015000 Manager2156000012500 Manager2445000012000 Staff3004500010000 Staff3354000010000 Staff400320007500 Entry-Level441280007500 Entry-Level

SELECT EMPLOYEEIDNO
FROM EMPLOYEESTATISTICSTABLE
WHERE POSITION = 'Manager' AND SALARY > 60000 OR BENEFITS > 12000;


Query1EmployeeIDNoPositionSalaryBenefits10Manager7500015000 105Manager6500015000 152Manager6000015000 215Manager6000012500 244Staff5000012000 400Entry-Level320007500 441Entry-Level280007500
 
Are you familiar with commas and spaces?

Bob
 
WHERE POSITION = 'Manager' AND SALARY > 60000 OR BENEFITS > 12000;

this could be treated as either

position is manager and salary over 60000
or benefits over 120000

OR

position is manager and
either the salary is over 60000 or the benefits are over 120000

---------
so i suspect your output is matching one of these, but not the one you expect - you will need to use some bracketing to force the expressions to be executed in a particular order

having said that, there must be more to your query, because the results include more columns than are in your sql statement - ie you are only asking for the employeeid, but that isnt what you are getting
 

Users who are viewing this thread

Back
Top Bottom