thomasrichardson2000 (10/11/2012)
RepairSheetNrunitnrgroupidbrandIdmodelIdversionType_Fleetclose_dateTotalModels500000384EDMNFIATGRANDE PUNTO 1.28V DYNAMIC 5DROF 2012-07-31 00:00:00.0001
Sorry the query ran fine, it just returned the exact same result set as the query I posted.
I need the total value to reflect the total number of that particular model on the fleet at present, for example in the case above i know there are 45 "GRANDE PUNTO 1.2 ", ineed the results to reflect this
That was the intention, Thomas - I made the query more readable for others, that's all 🙂
Are you only getting one row back with this query? If you are getting several, then it would be helpful if you could post a set of them embracing several models. Post in a readily-consumable format, like this:
CREATE TABLE #Temp (RepairSheetNr ?, unitnr ?, groupid ?, brandId ?, modelId ?, version ?, Type_Fleet ?, close_date DATETIME, TotalModels INT)
INSERT INTO #Temp
SELECT 5000003, 84, 'EDMN', 'FIAT','GRANDE PUNTO 1.2', '8V DYNAMIC 5DR', 'OF', '2012-07-31 00:00:00.000',1 UNION ALL
Don't forget to include the datatypes in the CREATE TABLE - replace ? with the correct type.
For better assistance in answering your questions, please read this[/url].
Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]