SQL Query Group By Datetime problem?

后端 未结 2 961
伪装坚强ぢ
伪装坚强ぢ 2021-01-16 20:55

I have this SQL query:

  SELECT DISTINCT 
         [BatchCode]
         ,SUM([Quantity]) as \'Created\'
         ,[TotalQuantity]
         ,[Status]
                 


        
2条回答
  •  离开以前
    2021-01-16 21:14

    Use CAST or CONVERT to alter the DATETIME format so the time portion is omitted:

      SELECT [BatchCode],
             SUM([Quantity]) as 'Created',
             [TotalQuantity],
             [Status],
             [Destination],
             CONVERT(VARCHAR(10), [DateCreated], 101) AS datecreated,
             [CreatedBy]
        FROM [FGIS].[dbo].[DropshipPackinglist]
    GROUP BY BatchCode, 
             TotalQuantity, 
             Status, 
             Destination, 
             CreatedBy, 
             ModifiedBy, 
             CONVERT(VARCHAR(10), [DateCreated], 101)
    

提交回复
热议问题