如何通过仅使用最大值并使用ASP.NET在gridview中显示来对值进行排序 [英] How to sort the values by taking only maximum values and showing in gridview using ASP.NET

查看:60
本文介绍了如何通过仅使用最大值并使用ASP.NET在gridview中显示来对值进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Machine Number 1	Employee Code1	KRISHNAPPA	5
Machine Number 1	Employee Code2  SHANKARAPPA	4
Machine Number 1        Employee Code3  MANGALYA 	4
Machine Number 2	Employee Code1	SHANKARAPPA	5
Machine Number 2	Employee Code2	ee	        4
Machine Number 2	Employee Code2	MANGALYA 	5
Machine Number 3	Employee Code3	SHANKARAPPA	5
Machine Number 3	Employee Code1	MANGALYA 	4



其实这里数据排序和显示......

但是在这个我需要的每台机器只需要最大值。在机器1(3或4个操作员)正在工作

i需要每个机器只需要最高技能值操作员..



我尝试过:




Actually here that data sorting and showing...
but in this i need take only Maximum Value for each machine. In Machine 1(3 or 4 Operator)are working
i need to take only highest skill value Operator for each machine..

What I have tried:

SqlCommand cmd1 = new SqlCommand();
              DataAccessNew da = new DataAccessNew();
              cmd1.CommandText = query;
              DataTable dt = da.ExecuteIntoDataTable(cmd1);

              DataView dv = dt.DefaultView;
              dv.Sort = "Skill desc";
              DataTable sortedDT = dv.ToTable();

              GridView2.DataSource = dt;
              GridView2.DataBind();



这个代码我尝试在数据表技能级别排序应该是降序5, 4,3,2,1但我需要从每台机器中获取最高价值。

每台机器在数据表中包含3或4个值..

请帮助我Frnds


this code i tried for sorting in data table skill level should be descending order 5,4,3,2,1 but i need to take only highest value from each machine.
Each Machine contains a 3 or 4 values in datatable..
Pls Help me Frnds

推荐答案

尝试:

Try:
SELECT MachineColumn, MAX(ValueColumn) AS [Value]
FROM MyTable
GROUP BY MachineColumn


这篇关于如何通过仅使用最大值并使用ASP.NET在gridview中显示来对值进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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