Query Select group by last character in field

前端 未结 1 1715
甜味超标
甜味超标 2021-01-28 07:47

I\'m trying to go a query search on a table and return a count of rows that end in the same character. For example Cd312a, fdhEA and 42dA would be grouped together under \'A\'

相关标签:
1条回答
  • 2021-01-28 08:23

    Before

    SELECT RIGHT(_Name,1) as Type, Count(Type) as Count
    FROM Tbl_Table
    

    After

    SELECT RIGHT(_Name,1) as Type, Count(*) as Count
    FROM Tbl_Table
    Group by RIGHT(_Name,1)
    Order by RIGHT(_Name,1)
    

    Edit

    Removed "Type" from the Count function to address the "Unknown column 'Type' in 'field list'" problem.

    0 讨论(0)
提交回复
热议问题