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

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

    I dont believe so, LIKE is effectively a binary state - something is LIKE or NOT LIKE, there are not logical degrees of 'likeness' that could be grouped together. Then again, I could be off my rocker.

    If what you really want is to express filtering over your grouped data take a look at the HAVING clause.

    http://msdn.microsoft.com/en-us/library/ms180199.aspx

提交回复
热议问题