Maybe someone alot more knowledgeable than me in SQL can explain this to me and there are certainly a lot of you.
When I run this query:
select make, count(*) totalNumber from VehicleModelYear where make='acura' and year=1987
group by make
I get correct results.
For instance, I do have, for testing purposes, 2 acura legends for the year 1987 and it is listed correctly as:
If, however, I run this query:
select vehicleId,( make+ '(' + CONVERT(NVARCHAR, (select count(*) from VehicleModelYear B where a.vehicleId=b.vehicleId)) + ')') as Make from VehicleModelYear A where a.Year = 1987 order by a.Make
I get the following results:
Any reason for the descrepancies and how do I resolve this?
Just a little history, I am building a car dealer web app.
Users will select Year from dropdownlist, say 1987.
Once this select is made, all vehicles and their Makes and models for the year 1987 are loaded into the second dropdown.
The functionality works but the results don't.
Your assistance is greatly appreciated.