我正在尝试获取特定日期的第一个收货号和最后一个收货号。有没有办法在一句话中得到它?我可以使用2条语句来获得它,如下所示:
cnn.Open()
query = "select top 1(invoice) from invoice_tbl where transaction_date = @transaction_date order by invoice Desc"
cmd = new sqlCommand(query,cnn)
.......
和
cnn.Open()
query = "select top 1(invoice) from invoice_tbl where transaction_date = @transaction_date order by invoice Asc"
cmd = new sqlCommand(query,cnn)
.......
我可以在单个语句中获取展位值并将其放置在变量中,以便将其分别放置在两个标签上吗?
谢谢!
尝试这个
select
(select top 1(invoice)
from invoice_tbl
where transaction_date = @transaction_date order by invoice Desc) as last_inv ,
(select top 1(invoice)
from invoice_tbl
where transaction_date = @transaction_date order by invoice Asc) as First_inv
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句