SQL:如果还有一列,如何计算一列的总数?
编辑:看来我解释得不够好。我会再试一次 我想退这个。如果SQL:如果还有一列,如何计算一列的总数?,sql,sql-server,Sql,Sql Server,编辑:看来我解释得不够好。我会再试一次 我想退这个。如果app\u type等于“软件更新”,则将接收的bytes\u和发送的bytes\u的值相加 app_type Bytes_received Bytes_sent ------------------------------------------------ software updates 10098120398214 09832140914 email 89032409 9
app\u type
等于“软件更新”,则将接收的bytes\u和发送的bytes\u的值相加
app_type Bytes_received Bytes_sent
------------------------------------------------
software updates 10098120398214 09832140914
email 89032409 9874398
下面的第一个查询返回并统计应用程序在数据中键入的所有时间。这是一个有70万条记录的大表格
第二个显示了“软件更新”条目使用的字节数
结束编辑
我有一个名为WirelessAppData
的表,我正在试图找出app\u type
列中数据的发送和接收流量总和。我添加了我尝试过的东西
我真的很想返回一个从最高到最低的表
app_type Bytes_received Bytes_sent
------------------------------------------------
software updates 10098120398214 09832140914
email 89032409 9874398
SELECT
app_type AS ['App Type'],
COUNT (*) AS ['Top App type']
FROM
dbo.WirelessAppData
GROUP BY
app_type
ORDER BY
['Top App type'] DESC;
Uncategorized App Type 143305
Tunnel 123024
Media 85947
Facebook 66698
Search Engine 62031
Social Networking 50168
Internet Utilities 48973
Instant Messaging 40977
File Sharing 19595
Games 13432
Internal 12700
Business 9333
iTunes 9298
Microsoft 8995
Webmail 4644
Software Updates 3301
select app_type, bytes_received, bytes_sent
from WirelessAppData
where app_type = 'Software Updates'
order by bytes_received desc;
Software Updates 465108871 551
Software Updates 460464329 930
Software Updates 460271605 864
Software Updates 374041259 941
Software Updates 354425776 950
Software Updates 344554876 823
Software Updates 297851528 772
Software Updates 289410332 933
Software Updates 267913740 989
```
你可以试试下面的方法-
select app_type, sum(bytes_received) as bytes_received ,sum(bytes_sent) as bytes_sent
from WirelessAppData
group by app_type
order by bytes_received desc
你期望的结果是什么?对不起。。我希望能得到像第一部分这样的东西的回报。不清楚你在问什么,但看起来你可能会从小组中受益。你需要在你的帖子中添加更多关于你实际上想做什么的细节。谢谢。这似乎很完美