看看下面的SQL语句
有错,
我一下不知道怎么改
请大家帮忙
谢谢
select count(*) from
(select a.associator_number,a.name,
d.blockID,b.serviceID,b.ItemName,b.Money,convert (nvarchar(10),b.BuyDateTime,120)as BuyDateTime,
c.DeptName,a.handset_number,a.tel_number
from
tb_Associator_Message a,tb_ConsumeCar b,tb_departments c ,tb_AssociatorCard d
where a.associator_number=d.associator_number and a.DeptId = c.DeptID and b.blockID = d. blockID)
有错,
我一下不知道怎么改
请大家帮忙
谢谢
select count(*) from
(select a.associator_number,a.name,
d.blockID,b.serviceID,b.ItemName,b.Money,convert (nvarchar(10),b.BuyDateTime,120)as BuyDateTime,
c.DeptName,a.handset_number,a.tel_number
from
tb_Associator_Message a,tb_ConsumeCar b,tb_departments c ,tb_AssociatorCard d
where a.associator_number=d.associator_number and a.DeptId = c.DeptID and b.blockID = d. blockID)
(select a.associator_number,a.name,
d.blockID,b.serviceID,b.ItemName,b.Money,convert (nvarchar(10),b.BuyDateTime,120)as BuyDateTime,
c.DeptName,a.handset_number,a.tel_number
from
tb_Associator_Message a,tb_ConsumeCar b,tb_departments c ,tb_AssociatorCard d
where a.associator_number=d.associator_number and a.DeptId = c.DeptID and b.blockID = d. blockID)G
不用使用子查询的,如:
select count(*) from tb_Associator_Message a,tb_ConsumeCar b,tb_departments c ,tb_AssociatorCard d
where a.associator_number=d.associator_number and a.DeptId = c.DeptID and b.blockID = d. blockID
如果非要使用的话,子查询后面加一个别名如:
select count(*) from
(select a.associator_number,a.name,d.blockID,b.serviceID,b.ItemName,b.Money,
convert (nvarchar(10),b.BuyDateTime,120)as BuyDateTime, c.DeptName,a.handset_number,a.tel_number
from tb_Associator_Message a,tb_ConsumeCar b,tb_departments c ,tb_AssociatorCard d
where a.associator_number=d.associator_number and a.DeptId = c.DeptID and b.blockID = d. blockID) A -- 加个A