这个sql语句很多毛病
1. order by password,OrderType
order by 后面的字段名不能用别名的,要用原来的字段名。而你的OrderType是 2 的别名。
2. A.password,'采购进货' as type
这个句话我都不懂是什么意思,你要让字段password的别名是'采购进货'还是type?应该是a.password as type
3. 在你的语句中有C.gysname ,B.ze 等字段,可是你并没有声明表b和表c叫什么名字
4. 2 as OrderType这个2到底是什么东西,我想只有你自己知道了
select * into #temp from
(
select type as 类型,gysname as 供应商名称,jhdh as 单号,ze as 总额,xmoney as 进项税额,zexmoney as 价税合计
from
(
select A.password,'采购进货' as type,C.gysname As gysname,A.jhdh,B.ze as ze,B.xmoney as xmoney,B.zexmoney as zexmoney, 2 as OrderType
From jhdb A,
order by password,OrderType
))
//Server: Msg 156, Level 15, State 1, Line 9
Incorrect syntax near the keyword 'order'.
这是什么错误