0
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我想要:

select top 1 proid from table_Renewal  order by renewalid desc

如何重新排列查询?

现在c.proid我有不止一个 id.so 它将检查所有 id。我只想检查

select top 1 proid from table_Renewal  order by renewalid desc
4

1 回答 1

0

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

从 table_Renewal 中选择 max(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 an inner join (select * from table_SuperAdmin as b inner join table_Renewal as c on b.S_id=c.supid left outer join (select max(proid) as proid1,supid from table_Renewal group by supid) as c1 on b.S_id=c1.supid where c1.proid1 in (select [plan]从 table_features where Fjobs=1) and c.Payed=1) as a on a.oid=aa.businessid where a.status=1 and a.lastdate>GETDATE() order by startdate desc

于 2013-03-22T13:00:49.220 回答