SQL grouping by month and year

后端 未结 9 1721
旧时难觅i
旧时难觅i 2020-11-27 15:57

I\'m not sure what should I write in the following SQL query to show \'date\' column like this: \"month-year\" - \"9-2011\".

SELECT MONTH(date) + \'.\' + YE         


        
9条回答
  •  一生所求
    2020-11-27 16:18

    In postgresql I can write a similar query with a date-format function (to_char) and grouping just by date:

    SELECT to_char (datum, 'MM-YYYY') AS mjesec 
    FROM test 
    GROUP BY datum 
    ORDER BY datum;
    

    Such thing is surely possible with SQL-Server too, isn't it?

提交回复
热议问题