Использовать функцию sum в запросе 2 таблицы 2 баз данных
hello, below is my query, the query result is 2 columns from 2 different databases the columns "OriginalPremium" & "Share" Share is always static in EACH query run but in some queries are 50 some are 60..etc the question: how to get the SUM of the "OriginalPremium" in my Query result ?? SELECT OriginalPremium, Users.Share FROM [URSYSTEM].[PolicyTable] a inner join [LoginDB].[ahsal-UR].Users on Producer = LoginDB.[ahsal-UR].Users.Username Now my output is: -------------------------- |OriginalPremium | Share | -------------------------- | 10 | 50 | -------------------------- | 5 | 50 | -------------------------- | 15 | 50 | -------------------------- what i want is: -------------------------- |OriginalPremium | Share | 30 | 50 | -------------------------- by the way i used Sum(OriginalPremium) as Total it shows me this error: Msg 8120, Level 16, State 1, Line 3 Column 'LoginDB.ahsal-UR.Users.Share' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Что я уже пробовал:
by the way i used Sum(OriginalPremium) as Total it shows me this error: Msg 8120, Level 16, State 1, Line 3 Column 'LoginDB.ahsal-UR.Users.Share' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.