MAX函数只选择10个值,但值大于10.帮我这个 [英] MAX function selecting just 10 values but values are more than 10. help me with this

查看:100
本文介绍了MAX函数只选择10个值,但值大于10.帮我这个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DECLARE @Installment_no VARCHAR(100) SELECT @Installment_no = Max(v.Installment_no) FROM Voucher_slip v,Loan l,Installments i,Customer c WHERE l.Loan_id=v.Loan_id and c.Loan_id=v.Loan_id and c.Customer_CNIC = ''12345-1234567-8''; 

Select ins.Transaction_no  from Voucher_slip v,Loan l,Installments i,Customer c,Installment_Payment ins where l.Loan_id=v.Loan_id and c.Loan_id=v.Loan_id and l.Loan_id=ins.Loan_id and c.Customer_CNIC = ''12345-1234567-8'' and ins.Transaction_no=@Installment_no

推荐答案

你好朋友,



如果你想从表中选择TOP 10值,那就用这样的东西......



Hello friend,

If you want to select TOP 10 values from your table then use something like this...

Select TOP 10 ins.Transaction_no  from Voucher_slip v,
Loan l,
Installments i,
Customer c,
Installment_Payment ins 
where l.Loan_id=v.Loan_id 
and c.Loan_id=v.Loan_id 
and l.Loan_id=ins.Loan_id 
and c.Customer_CNIC = '12345-1234567-8' 
ORDER BY v.Installment_no DESC







如果你只想从你的桌子中选择一个值,那就用这样的东西......






If you want to select only one value from your table then use something like this...

Select TOP 1 ins.Transaction_no  from Voucher_slip v,
Loan l,
Installments i,
Customer c,
Installment_Payment ins
where l.Loan_id=v.Loan_id
and c.Loan_id=v.Loan_id
and l.Loan_id=ins.Loan_id
and c.Customer_CNIC = '12345-1234567-8'
ORDER BY v.Installment_no DESC


嗨试试这个,





Hi Try this,


SELECT Transaction_no 
FROM Installment_Payment
WHERE Transaction_no IN( SELECT TOP 1 ins.Transaction_no  
				     FROM Voucher_slip v, Loan l, Installments i, Customer c, Installment_Payment ins
				     WHERE l.Loan_id=v.Loan_id
				     AND c.Loan_id=v.Loan_id
				     AND l.Loan_id=ins.Loan_id
				     AND c.Customer_CNIC = '12345-1234567-8'
				     ORDER BY v.Installment_no DESC)





问候,

GVPrabu



Regards,
GVPrabu


这篇关于MAX函数只选择10个值,但值大于10.帮我这个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆