T-SQL aggregate function Logical error
Ok I have a data table containing the duplicate Reciept numbers and the transaction value for each record, I just need to list the amount for each unique Reciept number, this is obviously a simple problem, but I am missing something.
Any help is multifaceted
SELECT Gf_Receipt_number AS Reciept,
SUM (Gf_Amount) AS Total
FROM [TestP].[dbo].[Gf]
WHERE Gf_Receipt_number IS NOT NULL
GROUP BY Gf_Amount
It probably helps to mention the error I'm getting:
The column "TestP.dbo.Gf.Gf_Receipt_number" is not valid in the picklist because it is not contained in either an aggregate function or a GROUP BY clause.
a source to share
You need to group by Gf_Receipt_number instead of Gf_Amount
The GROUP BY clause specifies which columns are used to distinguish one group of records from another, while the column used in aggregate functions (for example, SUM (Gf_Amount)) determines how other columns in those records are combined into one value.
a source to share
You will need to put the GF_Receipt_number in your group to clear the error. Group by refrence
a source to share