我在hackerrank上做了一个sql oj。我需要先命名具有相应计数的名称和订单职业的人。数据库表,如png图像显示table structure。 我想用
.tooltip-subtitle {
color: #EEEEEE;
max-width: 350px;
word-wrap: break-word;
font-style: italic;
font-size: 13px;
text-align: justify;
}
解决这个问题,但得到“[Err] 1111 - 无效使用群组功能”。 如果我按计数(职业)评论顺序可能没问题。或者只是使用
select type from
(
(
SELECT name as type, 1 as filter FROM occupations
order by name
)
UNION All
(
select concat(count(occupation), ' ', lower(occupation), 's.') as type, 2 as filter
FROM occupations
group by occupation
order by count(occupation)
)
) result
order by filter, type
也没关系,但一旦工会收到此错误
select concat(count(occupation), ' ', lower(occupation), 's.') as type, 2 as filter
FROM occupations
group by occupation
order by count(occupation)
但我将此联合复制到postgresql(更改字符串合约函数)没关系,没有此错误。postgresql is okay 在mysql中,我必须将此“按次数排序(占用)”设置为另一个临时表来解决此错误,如下所示:
(
SELECT name as type, 1 as filter FROM occupations
order by name
)
UNION All
(
select concat(count(occupation), ' ', lower(occupation), 's.') as type, 2 as filter
FROM occupations
group by occupation
order by count(occupation)
)
我很困惑,非常感谢你的帮助!
答案 0 :(得分:0)
order by
在工会中无效。将order by
移到联合操作之外。