Do You Want to Learn SQL?

Take our free eight day course, where I'll teach you in simple to understand English all you need to get started learning SQL.

-
DAYS
-
HOURS
-
MINUTES
-
SECONDS

Free Beginners SQL Course!

Question #1

Find all single female employees

SELECT NationalIDNumber,
       MaritalStatus,
       Gender
FROM   HumanResources.Employee
WHERE  MaritalStatus = 'S'
       AND Gender = 'F'

Question #2

Find all employees that have 40 to 80 hours of vacation time.

SELECT NationalIDNumber,
       MaritalStatus,
       Gender,
       VacationHours
  FROM HumanResources.Employee
 WHERE VacationHours >= 40
       AND VacationHours <= 80

Question #3

Find all employees that have 40 to 80 hours of vacation time or 40 to 80 hours of sick time,  and are male.

SELECT NationalIDNumber,
       MaritalStatus,
       Gender,
       VacationHours,
       SickLeaveHours
FROM   HumanResources.Employee
WHERE  (   (VacationHours >= 40 AND VacationHours <= 80)
        OR (SickLeaveHours >= 40 AND SickLeaveHours <= 80)
       )
       AND Gender = 'M'

Notice on this last example we used parenthesis to ensure the order of evaluating the clauses was correct.