将字节列转换或显示为MB的SQL查询?

问题描述 投票:5回答:2

我有一个查询为

select 
   sourceIP, SUM(sourceBytes) 
from 
   flows 
where 
   sourceBytes > 1000000 
group by 
   sourceIP

此查询将使在特定时间范围内在所有流中发送了超过100万字节的IP地址,您必须输入

结果类似于

------------------------------------
| sourceIP       | SUM_sourceBytes |
------------------------------------
| 64.124.201.151 |   4282590.0     |
| 10.105.2.10    |   4902509.0     |
| 10.103.70.243  |   2802715.0     |
| 10.103.77.143  |   3313370.0     |
| 10.105.32.29   |   2467183.0     |
| 10.105.96.148  |   8325356.0     |
| 10.103.73.206  |   1629768.0     |
------------------------------------

我希望源字节显示为MB格式。我是否需要嵌套查询?谢谢。

sql syntax
2个回答
8
投票

使用此表达式。 CONCAT是SQL Server 2012+,可处理数据类型


0
投票

感谢您的帮助!

© www.soinside.com 2019 - 2024. All rights reserved.