读书人

小弟我想从第二条sql语句的结果中查询

发布时间: 2012-02-06 15:52:44 作者: rapoo

我想从第二条sql语句的结果中查询信息怎么办??
select max(SupplyState) from ( )

select Supplyid,SupplyState,SupplyPrice,SupplierMark from PurchasePrice where Operators='YD' and Province='SD' and Code='' and Par='50'



我想从第二条sql语句的结果中查询信息怎么办??
把第二条sql放进第一条sql语句的()中不对吗?
怎么实现呢??



[解决办法]
select max(SupplyState) from (
select Supplyid,SupplyState,SupplyPrice,SupplierMark from PurchasePrice where Operators='YD' and Province='SD' and Code='' and Par='50'
) t

加上别名试一下。
[解决办法]

SQL code
select max(SupplyState) from (select Supplyid,SupplyState,SupplyPrice,SupplierMark from PurchasePrice where Operators='YD' and Province='SD' and Code='' and Par='50' ) t
[解决办法]
其实你直接用max即可,

SQL code
select max(SupplyState) from PurchasePrice where Operators='YD' and Province='SD' and Code='' and Par='50'
[解决办法]
select max(SupplyState)from PurchasePrice where Operators='YD' and Province='SD' and Code='' and Par='50'

只要直接从purchaseprice表中取数即可。

读书人网 >SQL Server

热点推荐