谁能解答SQL”第 2 行: 'sum' 附近有语法错误。”

来源:百度知道 编辑:UC知道 时间:2024/06/26 02:36:59
select companyname as 海运公司
sum(freight) as 运费总额
shipcountry as 目的地
from latinamerica
where orderid>=10700
group by companyname,shipcountry with rollup
group by companyname asc
运行后出现错误提示:
第 2 行: 'sum' 附近有语法错误。
freight是字段名,没有写错,原来是少了逗号,逗号加上后,运行后显示错误为:
在关键字 'group' 附近有语法错误。

select companyname as 海运公司,
sum(freight) as 运费总额,
shipcountry as 目的地 ,
没加豆号

补充:group by companyname asc

应该是 order by companyname asc

select companyname as 海运公司
sum(freight) as 运费总额
shipcountry as 目的地
from latinamerica
where orderid>=10700
group by companyname,shipcountry with rollup
order by companyname asc

select companyname as 海运公司,
sum(freight) as 运费总额,
shipcountry as 目的地,
from latinamerica
where orderid>=10700
group by companyname,shipcountry
with
rollup
group by companyname asc
应该是这个我在查询分析器上用了,显示from有错,没有表!~

freight是字段名吗?看看有没写错