Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table like this;

+--------+------------+-------------+
| itemID | item       | date        |
+--------+------------+-------------+
| 1      | event1     |  2012-09-05 |
| 2      | event2     |  2010-03-02 |
| 3      | event3     |  2012-11-01 |
| 4      | event4     |  2011-04-11 |
| 5      | event5     |  2011-05-08 |
| 6      | event6     |  2009-06-02 |
| 7      | event7     |  2011-07-04 |
| 8      | event8     |  2012-09-06 |
| 8      | event9     |  2011-08-11 |
+--------+------------+-------+-----+


I want to list all the years in which 2 or more events are occured in descending order.

Can you help me?

Posted
Updated 25-Nov-12 10:44am
v2

1 solution

SQL
SELECT YEAR(date)
FROM Event
GROUP BY YEAR(date)
HAVING COUNT(date) >= 2
ORDER BY date DESC
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900