【发布时间】:2019-12-17 20:55:15
【问题描述】:
想象一下人们在全球范围内访问谷歌网站的次数(ID、姓名、位置、谷歌(varchar)) 我要查询,以便结果显示如下
Name : No.of times : Location : Google Website
Joe : 2 : Singapore : google.com.sg
Kim : 3 : Japan : google.com.jp
就我的两分钱.....下面的查询对吗?
SELECT Name, Count(Name), Location, CASE WHEN Location = 'Singapore' THEN CONCAT('google','.com.sg')
WHEN Location = 'Japan' THEN CONCAT('google','.com.jp')
ELSE google END AS Website
FROM db1
GROUP BY Name, Location, Website
因为当我在select语句中添加CASE时,它一直说不是GROUP BY表达式,所以我想检查一下我的理解是否正确......
【问题讨论】: