1. We have moved to a new forum! There may be a few things not working properly so please let us know if you find a bug. Remember to use the bbCode [ sql ] tag for SQL statements.

How to form Query for details given?

Discussion in 'SQL - Questions and Answers' started by rizwanahmed23, Nov 20, 2006.

  1. rizwanahmed23 New Member

    Dialect: MS SQL
    there is a table 'Emptable' having columns 'empid' and 'datetime' we have to retrieve empid's of employee who had loged m0re than or equalto 5 times past week.
  2. ben Administrator

    Dialect: MySQL
    This should work with MS SQL as well

    SQL:

    SELECT empid FROM Emptable
    WHERE datetime > (CURRENT_TIMESTAMP + INTERVAL '-7' DAY)
    GROUP BY empid
    HAVING count(empid) >= 5

Share This Page