如何删除数据集中的列和不同的行以仅查找组名称?

发布于 2024-07-19 14:09:30 字数 892 浏览 2 评论 0原文

我有 3 列的数据集。

Name    -    insurance comp. name     -     treatmentDate
Ali Boz      SGK                            12.04.09
Ali Boz      SGK                            14.04.09
Ali Boz      SGK                            16.04.09
Ali Boz      SGK                            18.04.09
Veli Aş      AKBANK                         10.04.09
Veli Aş      AKBANK                         11.04.09
Veli Aş      AKBANK                         12.04.09
Veli Aş      AKBANK                         13.04.09
Cuneyt Sel   ING BANK                       01.05.09
Cuneyt Sel   ING BANK                       02.05.09
Cuneyt Sel   ING BANK                       05.05.09
Cuneyt Sel   ING BANK                       19.05.09

我想首先只找到保险公司。 名称

SGK
AKBANK
ING BANK

然后我想按名称和日期排序

但是数据集中的所有这些内容(因为我想从数据库检索所有行)。

你对我有什么建议吗?

I have DataSet which has 3 columns.

Name    -    insurance comp. name     -     treatmentDate
Ali Boz      SGK                            12.04.09
Ali Boz      SGK                            14.04.09
Ali Boz      SGK                            16.04.09
Ali Boz      SGK                            18.04.09
Veli Aş      AKBANK                         10.04.09
Veli Aş      AKBANK                         11.04.09
Veli Aş      AKBANK                         12.04.09
Veli Aş      AKBANK                         13.04.09
Cuneyt Sel   ING BANK                       01.05.09
Cuneyt Sel   ING BANK                       02.05.09
Cuneyt Sel   ING BANK                       05.05.09
Cuneyt Sel   ING BANK                       19.05.09

I want to firstly find only insurance comp. names

SGK
AKBANK
ING BANK

Then i want to sort by name and date

But all those things in a DataSet (cause i want to retrive all rows from db).

Do you have any advice to me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

暮凉 2024-07-26 14:09:31

不确定您到底要问什么,但要检索保险公司名称,您可以简单地执行以下操作:

SELECT DISTINCT [insurance comp. name]
FROM [tablename]

按您提到的方式对所有记录进行排序:

SELECT *
FROM [tablename]
ORDER BY [insurance comp. name], [name], [treatmentdate]

Not sure what exactly your asking, but to retrieve insurance company names, you could simply execute the following:

SELECT DISTINCT [insurance comp. name]
FROM [tablename]

To sort all records as you mentioned:

SELECT *
FROM [tablename]
ORDER BY [insurance comp. name], [name], [treatmentdate]
︶ ̄淡然 2024-07-26 14:09:31

使用 DataView.ToTable 非常简单:

DataView view = new DataView(table);
DataTable distinctTable = view.ToTable(true, "insurance comp. name");

It's pretty simple using DataView.ToTable :

DataView view = new DataView(table);
DataTable distinctTable = view.ToTable(true, "insurance comp. name");
偏爱自由 2024-07-26 14:09:30

如果您可以使用 LINQ,这将为您提供保险公司名称:

var Names = (from Row in YourDataSet.YourTable
             select Row.InsuranceCompanyName).Distinct();

您还可以添加 .ToArray().ToList()orderby 如有必要,取决于您的需求。

如果您无法使用 LINQ 或更改 SQL 调用,则会更加复杂< /a>.

If you can use LINQ, this will give you the insurance company names:

var Names = (from Row in YourDataSet.YourTable
             select Row.InsuranceCompanyName).Distinct();

You could also add .ToArray() or .ToList() or orderby depending on your needs, if necessary.

If you can't use LINQ or change the SQL call, it's more complicated.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文