需要帮助sql语句从我的表中查找值 [英] need help with sql statement to find a value from my table

查看:82
本文介绍了需要帮助sql语句从我的表中查找值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是SQL表,我需要使用VB.NET和MS SQL 2012为随机贷款金额和贷款期限找到合适的Doc费用。



Ex:

贷款金额= 6000

贷款期限= 35天



This is the SQL table and i need to find suitable Doc charges for a random Loan Amount and Loan Period.i'm using VB.NET and MS SQL 2012.

Ex:
Loan Amount = 6000
Loan Period = 35 days

Loan Amount   Loan Period   Doc charges
5,000.00        30            100.00
5,000.00        60            100.00
10,000.00       30            200.00
10,000.00       60            200.00
10,000.00       90            300.00
15,000.00       30            300.00
15,000.00       60            300.00
15,000.00       90            450.00
15,000.00       120           450.00

推荐答案

如果想法是为了获取下一个收费水平,以防金额或期间不等于表中的确切值,那么可能就像

If the idea is to fetch the 'next' charge level in case the amount or period is not equal to the exact value in the table then perhaps something like
SELECT TOP 1 a.[Doc charges]
FROM  TableName a
WHERE a.[Loan Amount] >= 6000
AND   a.[Loan Period] >= 35
ORDER BY a.[Loan Amount],
         a.[Loan Period]


这篇关于需要帮助sql语句从我的表中查找值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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