返回首页

我有一个查询,从多个表中选择数据。
我首先从表中选择100条记录,接下来我要选择的基础上像RegNo特别列在我的情况下100记录;
我使用子查询的方法,但子查询没有允许多张列。

我的查询是

Select Top 100

RegNo,

PatientName,

FCNo,

RelationName,

G.Description Gender,

DATEDIFF(YYYY,DOB,GETDATE())'Age',

R.Deleted

 

FROM PRS.dbo.tblRegistration R

LEFT OUTER JOIN TKC.dbo.tblGender G ON R.GenderID=G.GenderID

 

WHERE

Regno NOT IN

(

  SELECT TOP 0

  Regno RegNo,

  PatientName,

  FCNo,

  RelationName,

  G.Description Gender,

  DATEDIFF(YYYY,DOB,GETDATE())'Age',

  R.Deleted

 

  FROM PRS.dbo.tblRegistration R

  LEFT OUTER JOIN TKC.dbo.tblGender G ON R.GenderID=G.GenderID

  ORDER BY Regno

)

 

ORDER BY Regno

在那里为0的子查询,我使用一个变量的变化,每一次迭代。
然后99比199等....如0
预先感谢

回答

评论会员: 时间:2
m