Help in Sql Query

I have a database table with following cols

Id, Name, Date (FORMAT: Y-m-d H:i:s)

Now I want to retrieve data of following form

Count Year
3 2013
5 2014

It is showing total no of records generated in different years

For eg If I have following data

1 Manish 2013-10-01 23:12:12
2 Tarun 2013-10-02 23:12:12
3 Pankaj 2014-10-02 23:12:12
4 Pankaj 2015-10-02 23:12:12,

Then it will return me following data

Count Year
2 2013
1 2014
1 2015

Is it possible?

Replies

  • Anoop Kumar
    Anoop Kumar
    select count(YourDateCol), to_char(YourDateCol,'YYYY') from YourTable group by YourDateCol order by YourDateCol asc;
  • Shailaja Tiwari
    Shailaja Tiwari
    I'm not sure about this as I'm still learning but just check using
    Count() and group by clause applied on year.

    I don't have a datbase in my PC otherwise I could have myself checked it out.

You are reading an archived discussion.

Related Posts

I am looking for educational videos that can be downloaded from Youtube. Like Megafactories, Megastructures. Do you have any suggestions?
Hi, I am a final year student of Mechanical Engineering at the University of Pune [2003 syllabus] I just received my results. Of the 10 theory papers, I have cleared...
The motorcycle aficionados around the world should have taken note of the Castrol Rocket - soon to be the world's fastest motorcycle with a record breaking speed of about 606...
The WikiLeaks server that hosted the site during the release of classified US State Department docs, is now available on eBay for $25,200. The server belongs to Swedish Internet service...
If you're a Founder looking for an equally awesome Co-Founder, here's your chance to meet your ideal match at the Startup Saturday Gurgaon - Cofounder Search! When: September 14th, 2013...