'strftime' is not a recognized built-in function name

前端 未结 1 604
别那么骄傲
别那么骄傲 2021-01-25 08:27

I am using Microsoft SQL Database Management Studio and it will not allow me to use the strftime() function to run a query. I have to create a table by months with new users and

相关标签:
1条回答
  • 2021-01-25 09:18

    strftime is a mysql function, and isn't available in Microsoft's sql-server.

    For this simple usecase (extracting a month from a date), you could user month:

    SELECT   MONTH(createddate) AS [Month], 
             COUNT(createddate) AS [Subscribers],
             COUNT(dateunsubscribed) AS [UNsubscribers]
    FROM     subscriber
    GROUP BY 1
    ORDER BY 1;
    

    EDIT:
    To address the question in the comment, the group by clause doesn't take an ordinal like the order by clause does. You'll need to specify the expression you want to group by:

    SELECT   MONTH(createddate) AS [Month], 
             COUNT(createddate) AS [Subscribers],
             COUNT(dateunsubscribed) AS [UNsubscribers]
    FROM     subscriber
    GROUP BY 1
    ORDER BY MONTH(createddate);
    
    0 讨论(0)
提交回复
热议问题