I am building a mini-portal/website and I need to select values with the same DateTime.
For example, the first three values have the same DateTime and I would like to select them, yet I don’t know how the SQL code should look like.
Advertisement
Answer
This selects those records which has the same date
attribute and orders them by the date
attribute.
SELECT T2.* FROM ( SELECT date FROM TABLENAME GROUP BY date HAVING COUNT(date) >= 2 ) T1 JOIN TABLENAME T2 ON T1.date = T2.date ORDER BY date