So here is the context : Developping an ASP.NET MVC 4 web app, I have in my database a table ProductAllocations which is composed of 2 foreign keys : one from m
The fields you group by, you need to either use an aggregation sum
, max
etc or you need to include the columns in the clause, see the following links: SQL Group By & summarizing values
SELECT p.FirstName
,p.LastName
,pa.EndDate
,pr.PurchaseDate
,pr.SerialNumber
,pr.CatalogPrice
,v.PlateNumber
,v.FirstCirculationDate
,v.FirstDrivingTax
,v.UsualDrivingTax
FROM bm_ProductAllocations AS pa
INNER JOIN bm_Persons AS p ON pa.Id_Person = p.Id_Person
INNER JOIN bm_Products AS pr ON pa.Id_Product = pr.Id_Product
INNER JOIN bm_Vehicles AS v ON pr.Id_Product = v.Id_Product
GROUP BY pa.Id_Product
,p.FirstName
,p.LastName
,pa.EndDate
,pr.PurchaseDate
,pr.SerialNumber
,pr.CatalogPrice
,v.PlateNumber
,v.FirstCirculationDate
,v.FirstDrivingTax
,v.UsualDrivingTax;