我如何在aspx.vb中通过sql添加组

时间:2013-04-23 12:05:38

标签: asp.net sql vb.net

IN SQL:

select SE.shipperId, SUM(SEDetail.totalSize) as CBM from SE, SEDetail
where SEDetail.shipperId=10011 and SE.id = SEDetail.bolId and SEDetail.containerId
between 1 and 5 group by SE.shipperID

我已经改变了,这在aspx.vb中起作用:

SELECT SE.shipperID as 'Shipper ID', SUM(SEDetail.totalSize) as CBM 
FROM SE inner join SEDetail on SE.id = SEDetail.bolId and SEDetail.containerId 
between 1 and 5 Where

但是当我在sql:

中添加group by时出错
SELECT SE.shipperID as 'Shipper ID', SUM(SEDetail.totalSize) as CBM 
FROM SE inner join SEDetail on SE.id = SEDetail.bolId and SEDetail.containerId 
between 1 and 5 Where group by SE.shipperID

如何在一个sql中使用它?

1 个答案:

答案 0 :(得分:1)

只需删除WHERE

即可
SELECT SE.shipperID as 'Shipper ID', SUM(SEDetail.totalSize) as CBM 
FROM SE inner join SEDetail on SE.id = SEDetail.bolId WHERE SEDetail.containerId 
between 1 and 5 group by SE.shipperID