SQL SERVER CE子查询异常

时间:2012-08-16 13:42:32

标签: c# sql-server-ce

下面是我想要执行的子查询,但VC#2010在执行时会生成异常。

查询:

("SELECT U.Name 
  FROM Users U,Installments I 
  WHERE U.ID=I.ID 
  AND I.Sr=(SELECT MAX(Sr) FROM Installments Group By ID ) 
  AND I.Date=(SELECT Date FROM Installments GROUP BY ID HAVING(Sr=Max(Sr)))"
 , Con))

例外:

  

解析查询时出错[令牌行号= 1,令牌行偏移= 69令牌错误=选择]

1 个答案:

答案 0 :(得分:0)

您的查询不应该是SELECT U.Name FROM Users AS U,Installments AS I WHERE U.ID=I.ID AND I.Sr=(SELECT MAX(Sr) FROM Installments Group By ID ) AND I.Date=(SELECT Date FROM Installments GROUP BY ID HAVING(Sr=Max(Sr)))吗?您没有将表格指定为U和I,只是将字母放在表格名称之后。