【问题标题】:Remove Duplicate rows from DataGrid从 DataGrid 中删除重复的行
【发布时间】:2016-08-20 02:52:11
【问题描述】:

我正在使用 ASP.NET DataGrid 类。 asp:DataGrid我想根据以下条件删除某些行。

例如:

Complaint-Number        Attempts   Time
6000000939              1          11:02:00
6000000939              2          11:04:00
6000000939              3          11:09:00

我只想保留那些尝试次数最多的投诉。

Complaint-Number        Attempts   Time
6000000939              3          11:09:00

我尝试了这个示例但仍然没有运气Eliminate Duplicate

注意:请注意,我使用的是 asp:DataGrid 类。

请找到我的报告截图供您参考。

【问题讨论】:

    标签: c# asp.net datagrid


    【解决方案1】:

    在您的 Select 声明中尝试这样的操作。:

    SELECT *
    FROM yourTable 
    WHERE (Attempts IN
                   (SELECT MAX(Attempts) AS Expr1
                    FROM yourTable AS yourTable_1))
    

    它被称为Subquery,您可以在此处阅读更多信息:Subquery Fundamentals

    【讨论】:

    • 这是解决我的问题WHERE A.attempt in (SELECT MAX(B.attempt) FROM AutoRectifier1 B WHERE A.TICKET_NO = B.TICKET_NO)
    【解决方案2】:

    SELECT DISTINCT Complaint-Number FROM yourtable ORDER BY Attempts ASC

    您可以根据需要使用 ORDER BY Attempts DESC。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-21
      • 1970-01-01
      • 2012-10-21
      • 2017-10-11
      相关资源
      最近更新 更多