请问这句SELECT查询语句哪错了?谢谢(50分)

  • 主题发起人 主题发起人 clonesea
  • 开始时间 开始时间
C

clonesea

Unregistered / Unconfirmed
GUEST, unregistred user!
SELECT round( (Vote.Vote/(Case M.SumVote When M.SumVote=0 then
1 else
M.SumVote end ))*100,0)AS AvgVote FROM (VoteType INNER JOIN Vote ON VoteType.ID = Vote.TypeKind) INNER JOIN (SELECT VoteType.ID, sum(Vote.Vote)as SumVote FROM VoteType INNER JOIN Vote ON VoteType.ID = Vote.TypeKind GROUP BY VoteType.ID) M ON VoteType.ID = M.ID WHERE (VoteType.ID = "&ID&") ORDER BY VoteType.ID, Vote.ID
 
眼花了。下次再来看。
 

是不是GROUP BY 错了.
没有错误提示吗?
 
眼晕,对齐一下发嘛
 
应该是INNER JOIN 不对应,可以先将一部执行,然后在一部份执行
 
你最后的where字句是干什么的,好像有些问题把?
 
SELECT VoteType.ID, VoteType.TypeName, VoteType.IsDefault, VoteType.DateTime,
M.SumVote, Vote.Title, Vote.Vote,
round( (Vote.Vote/Case When M.SumVote=0 then
1 else
M.SumVote end )*100,0)
AS AvgVote,
round( (Vote.Vote/Case When M.SumVote=0 then
1 else
M.SumVote end )*100,0)*2 as Lng
FROM VoteType INNER JOIN
Vote ON VoteType.ID = Vote.TypeKind INNER JOIN
(SELECT VoteType.ID, sum(Vote.Vote)as SumVote FROM VoteType INNER JOIN Vote ON VoteType.ID = Vote.TypeKind GROUP BY VoteType.ID) M
ON VoteType.ID = M.ID
WHERE (VoteType.ID = 参数@ID)
ORDER BY VoteType.ID, Vote.ID
 
(SELECT VoteType.ID, sum(Vote.Vote)as SumVote FROM VoteType INNER JOIN Vote ON VoteType.ID = Vote.TypeKind GROUP BY VoteType.ID) M
这句应该怎么写?
 
解决了。用临时表
 
后退
顶部