我有一个查询,其中返回的某些列是sum()函数的结果,并且该列名为“ sum(price)”,但我希望列名称为“ total”。有没有办法在SQLite中做到这一点?
查询:
SELECT name, sum(price) FROM trades WHERE trader_id = 7 group by symbol;
电流输出:
+------------+-------------+
| name | sum(shares) |
+--------------------------+
| netflix | 523.26|
+--------------------------+
| tesla | 9276.06|
+------------+-------------+
预期输出:
+------------+-------------+
| name | total |
+--------------------------+
| netflix | 523.26|
+--------------------------+
| tesla | 9276.06|
+------------+-------------+
在as total
不正是你所期待的。它创建一个别名。
SELECT name, sum(price) as total FROM trades WHERE trader_id = 7 group by symbol;
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句