Sql server 2008 如何为联接中的列编写查询

Sql server 2008 如何为联接中的列编写查询,sql-server-2008,Sql Server 2008,在上面的查询c.proid中,我希望如下所示: select top 2 CONVERT(varchar(6),a.lastdate,6) as lastdate ,(select name from table_states where ID=a.joblocation ) as locat ,* from table_jobpost as a inner join (select * from table_SuperAdmin as

在上面的查询c.proid中,我希望如下所示:

select top 2  
    CONVERT(varchar(6),a.lastdate,6) as lastdate
    ,(select name from table_states where ID=a.joblocation ) as locat
    ,* 
from table_jobpost as a 
inner join (select * 
            from table_SuperAdmin as b 
            inner join table_Renewal as c on b.S_id=c.supid 
            where **c.proid** in (select [plan] 
                                    from table_features 
                                    where Fjobs=1) 
            and c.Payed=1) as aa on a.oid=aa.businessid 
where a.status=1 
and a.lastdate>GETDATE() 
order by startdate desc
如何重新安排查询

现在在c.proid中,我有多个id,所以它将检查所有id。我只想检查一下

select top 1 proid from table_Renewal  order by renewalid desc

不确定我是否正确理解了你的问题。但请看下面我的答案

从表\u中选择maxproid

你能试试这个吗

选择前2名 CONVERTvarchar6,a.lastdate,6作为lastdate ,从ID=a的表_状态中选择名称 ,* 从表_jobpost作为 内部联接选择* 从表_SuperAdmin as b 内部联接表\u更新为b.S上的c\u id=c.supid 左外部联接选择maxproid作为proid1,supid作为b.S上的c1,从表\u续订组中选择supid\u id=c1.supid 其中c1.proid1在选择[计划]中 从表中选择功能 其中Fjobs=1 c.Payed=1,作为a.oid=aa.businessid上的aa 其中a.status=1 和a.lastdate>GETDATE
按startdate desc下单

先生,我怎样才能在上述查询中的c.proid处写下相同的内容
select top 1 proid from table_Renewal  order by renewalid desc