关于SQL SERVER查询,多行值,只显示一行!

select plucode as 编码,barcode as 条码
from txtplu
where plucode=99999

得到的结果显示很多行,我只要最后一行,应该如果修改这条语句?
谢谢!
你没有明白我的意思啊,
排序之后同样也是显示很多行啊
我的意思是只要最后一行

这个是按编码排序
select top1 plucode as 编码,barcode as 条码 from txtplu
where plucode=99999 order by plucode desc

这个是按条码排序
select top1 plucode as 编码,barcode as 条码 from txtplu
where plucode=99999 order by barcode desc

我知道啊,加了个top1 ,就是显示第一行的意思,desc是排倒序,也就是你要选的最后一行
温馨提示:内容为网友见解,仅供参考
第1个回答  2007-10-15
有很多种方法可以实现,现告诉你最简单的一个办法:
将你查询出来的多行into到一张临时表上,然后再在临时表上取最后一行值.
相似回答