使用VB从数据库获取具有相同值的最大数量 [英] Getting maximum number with same values from database using VB

查看:70
本文介绍了使用VB从数据库获取具有相同值的最大数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的职业数据库中有一个数字序列,并为2个人标记列:

具有唯一ID的案例1:
生涯-分数:
k1-10
k2-10
k3-9
k4-8
k5-10
k6-7
k7-6


具有唯一ID的情况2:
生涯-分数:
k1-5
k2-2
k3-9
k4-8
k5-4
k6-7
k7-6

我的系统就是一次分析一个人的职业发展.对于案例1,10是最大的数字,代表3个职业.
但是对于其他用户,可能是只有1个职业拥有最大人数的情况.
可能还有其他情况,所有k1到k7都具有相同的值,我也想将它们显示在标签中.

我的问题是:
如何在Visual Studio中检索具有最大数量(标记)的职业名称并将其分配给标签为aspx形式的标签? .
我需要VB中的代码.

I have a sequence of number in database in career and marks columns for 2 person:

Case 1 with unique ID:
career - marks:
k1 - 10
k2 - 10
k3 - 9
k4 - 8
k5 - 10
k6 - 7
k7 - 6


Case 2 with unique ID:
career - marks:
k1 - 5
k2 - 2
k3 - 9
k4 - 8
k5 - 4
k6 - 7
k7 - 6

My system is all about analyzing the marks of the career for one person in a time. For Case 1, 10 is the largest number which it represents 3 careers.
But for other users, it might be a case where only 1 career has the maximum number.
It might be other cases too where all k1 until k7 have the same value and I want to display them into the labels too.

My question is:
How can i retrieve the career''s name with the maximum number(marks) and assign it into the labels in aspx form in visual studio? .
I need the code in VB.

推荐答案

如果您想知道SQL如何获得最高分,那么您的查询可能类似于:
If you''re wondering about the SQL how to get the careers with maximum marks, then your query could be something like:
SELECT * 
FROM Career
WHERE Marks = (SELECT MAX(Marks)
               FROM Career)

很可能您需要在查询的外部和内部添加条件,例如人员ID或用于限制查询的内容单身人士(据我了解,您确实如此).

Most likely you need to add conditions to both outer and inner parts of the query, like the person ID or whatever you use to restrict the query to single person (as I understood that you do).


这篇关于使用VB从数据库获取具有相同值的最大数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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