I have this union market with () below.
I just wonder if it's possible to add SUM(Quantity), SUM(Turnover), SUM(TurnoverTarget), CONVERT(DATE, Datetime), DATEPART(HOUR, Datetime). in the same Union marked with () below
(*)insert INTO [Transform].PosSalesUnion
(DeviceId, DayClosureId, TransactionId, IndetId, TicketId, CategoryId, ArticleId, CurrencyId, Datetime, IsSuccessful, Quantity, Turnover, TurnoverTarget, SalesTransactionTypeId, ValidFrom, ValidTo, SerialNumber, poolID)
SELECT DeviceId, DayClosureId, TransactionId, IndetId, TicketId, CategoryId, ArticleId, CurrencyId, Datetime, IsSuccessful, Quantity, Turnover, TurnoverTarget, SalesTransactionTypeId, ValidFrom, ValidTo, SerialNumber, poolID FROM [Transform].Devices_DeviceGroups_PosSales
UNION
SELECT DeviceId, DayClosureId, TransactionId, IndetId, TicketId, CategoryId, ArticleId, CurrencyId, Datetime, IsSuccessful, Quantity, Turnover, TurnoverTarget, SalesTransactionTypeId, ValidFrom, ValidTo, SerialNumber,NULL FROM [Transform].PosSalesNotMatch