T-SQL - GROUP BY with LIKE - is this possible?

后端 未结 8 1166
失恋的感觉
失恋的感觉 2020-12-10 03:55

Is there a way to include a LIKE expression in a GROUP BY query? For example:

SELECT Count(*) 
FROM tblWhatever
GROUP BY column_x [LIKE %Fall-2009%]
         


        
8条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-10 04:24

    How about this:

    SELECT MAX(column_x) AS column_x 
    FROM (
        SELECT column_x 
        FROM tblWhatever 
        WHERE (UPPER(column_x) LIKE  '%Fall-2009%')
    ) AS derivedtbl_1 GROUP BY column_x
    

提交回复
热议问题