SQL query question: SELECT … NOT IN

前端 未结 7 1190

I am sure making a silly mistake but I can\'t figure what:

In SQL Server 2005 I am trying select all customers except those who have made a reservation before 2 AM.<

7条回答
  •  清歌不尽
    2020-12-24 05:41

    Given it's SQL 2005, you can also try this It's similar to Oracle's MINUS command (opposite of UNION)

    But I would also suggest adding the DATEPART ( hour, insertDate) column for debug

    SELECT idCustomer FROM reservations 
    EXCEPT
    SELECT idCustomer FROM reservations WHERE DATEPART ( hour, insertDate) < 2
    

提交回复
热议问题