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

后端 未结 8 1153
失恋的感觉
失恋的感觉 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:31

    If your courses always take five letters, you can keep it really simple:

    SELECT substring(column_x,5,100), count(*)
    FROM YourTable
    GROUP BY substring(column_x,5,100)
    

    Otherwise, check Peters or Rexem's answer.

提交回复
热议问题