我有一个查询使用在UNION ALL
select username,amount from employee
union all
select '' as username,sum(amount) from employee
order by cast(username as decimal)
用户名的启动顺序从1000
当我使用这个查询它总是显示最高的用户名,以最小的用户名
我想显示最小用户名到最高用户名
我为此做了什么?
我有一个查询使用在UNION ALL
select username,amount from employee
union all
select '' as username,sum(amount) from employee
order by cast(username as decimal)
用户名的启动顺序从1000
当我使用这个查询它总是显示最高的用户名,以最小的用户名
我想显示最小用户名到最高用户名
我为此做了什么?
尝试通过在子查询包裹的,
SELECT *
FROM
(
SELECT username, amount from employee
UNION ALL
SELECT '' as username, sum(amount) from employee
) x
ORDER BY (CASE WHEN username = '' THEN 1 ELSE 0 END) ASC,
CAST(username AS SIGNED) ASC
为了通过投(用户名作为十进制)递减 –
是什么'username'的数据类型?用户名的样本记录是什么? –
数据类型是varchar – noushad