Selecting multiple rows where column value on some of them is the same

I’ve seen other posts about this topic, but I’m pretty bad with SQL, so I can’t figure how to adapt it to my problem, so, here goes:

I’ve got a table Commissions, like this:

  • Difference between different datasources
  • SQL View: ORA Error
  • Entity Framework Indexing ALL foreign key columns
  • Find Distinct Dates from Varchar Datetime column
  • Get Specific Info From SQL Error Message 547
  • Calling a stored procedure results in an incorrectly empty DataTable
  • Id || No || GroupNo || Type || CreationDate || Details || Workshop
    1     45      2        TypeA      15:50         Hello.    NiceRepair
    2     50      2        TypeA      15:50         Hello.    QuickFix
    7     85      3        TypeA      16:26         Howdy.    NiceRepair

    I want to select the GroupNo, Type, CreationDate and Details fields, but I’m having trouble.

    Tried to Order By GroupNo but it caused an error.

    How can I build a select statement that will return something like this: (single row, not only for id = 2 but for all ids > 0)

    GroupNo || Type || CreationDate || Details
       2       TypeA     15:50         Hello.
       3       TypeA     16:26         Howdy.

    2 Solutions collect form web for “Selecting multiple rows where column value on some of them is the same”

    No need for the Group By, a simple DISTINCT should do the trick

    Select Distinct GroupNo, Type, CreationDate, Details
     From YourTable

    If you are still getting multiple rows

    Select GroupNo
          ,Type = max(Type)
          ,CreationDate = max(CreationDate)
          ,Details = max(Details)
     From YourTable
     Group By GroupNo
    select GroupNo,Type,CreationDate,Details
    From table
    group by GroupNo,Type,CreationDate,Details
    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.