MS SQL Server data consolidation

At the office we need to consolidate a MS SQL table, we should get 1 line per Quotaion number.
See Table: https://drive.google.com/file/d/0B8AuHxQASEWyaEhfSVpDT3lIV1U/view?usp=sharing

Tried using SELECT DISTINCT but can’t get it.

  • Get top 5 values with lambda query
  • Sql Server CTE “multi- part identifier could not be bound.”
  • Convert row data to column in SQL Server
  • Real vs. Floating Point vs. Money
  • Help with SQL Server Trigger to truncate bad data before insert
  • Are there any utilities to extract binary data from SQL Server?
  • SQL Server query:

        SELECT DISTINCT ([QuotationNumber])
          ,[CreationDate]
          ,[QuotationDate]
          ,[CustomerNumber]
          ,[CustomerName]
          ,[SalesPersonName]
          ,[Rreg]
          ,[ProductDescription]
          ,[FamilyDescription]
          ,[NameVariant]
          ,[StringValue]
    FROM [ABC].[dbo].[DEF]
    WHERE [CreationDate] > "2017-05-08 00:00:00.000"
    ORDER BY [CreationDate] DESC
    

    One Solution collect form web for “MS SQL Server data consolidation”

    If you keep all the column, you can’t. Either you remove [FamilyDescription], [NameVariant], [StringValue] from your select or you add new columns for those values in your destination result.

    SELECT DISTINCT ([QuotationNumber])
          ,[CreationDate]
          ,[QuotationDate]
          ,[CustomerNumber]
          ,[CustomerName]
          ,[SalesPersonName]
          ,[Rreg]
          ,[ProductDescription]
    FROM [ABC].[dbo].[DEF]
    WHERE [CreationDate] > "2017-05-08 00:00:00.000"
    ORDER BY [CreationDate] DESC
    

    There is what you should do to keep all values:

    SELECT DISTINCT [QuotationNumber]
          ,[CreationDate]
          ,[QuotationDate]
          ,[CustomerNumber]
          ,[CustomerName]
          ,[SalesPersonName]
          ,[Rreg]
          ,[ProductDescription]
          ,MIN([FamilyDescription]) [FamilyDescription]
          ,MAX(CASE WHEN NameVariant = 'DT_residual' THEN StringValue END) [DT_residual]
          ,MAX(CASE WHEN NameVariant = 'DT_interestRateSum' THEN StringValue END) [DT_interestRateSum]
          ,MAX(CASE WHEN NameVariant = 'DT_depositValue' THEN StringValue END) [DT_depositValue]
    FROM [ABC].[dbo].[DEF]
    GROUP BY [QuotationNumber]
          ,[CreationDate]
          ,[QuotationDate]
          ,[CustomerNumber]
          ,[CustomerName]
          ,[SalesPersonName]
          ,[Rreg]
          ,[ProductDescription]
    HAVING [CreationDate] > "2017-05-08 00:00:00.000"
    ORDER BY [CreationDate] DESC
    
    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.