select make, count(*) totalNumber from VehicleModelYear where make='acura' and year=1987
group by make
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
ASKER
select vehicleId, Year,
( make+ '(' + CONVERT(NVARCHAR, count(*) over (partition by a.Make, a.Year) ) + ')') as Make
from VehicleModelYear A
order by a.Make
ASKER
select DISTINCT Year from VehicleModelYear ORDER BY Year DESC
cmd.Parameters.AddWithValue("@year", _
ddlYear.SelectedItem.Value)
select distinct
( make+ '(' + CONVERT(NVARCHAR, count(*) over (partition by Make) ) + ')') as Make
from VehicleModelYear A
where a.Year = 1987
ASKER
without year
YEAR | Select Make
>>Year | Acura (2)
2013 | Audi (1)
2012 | BMW (1)
2011 | Cadillac (2)
2010 | Crysler (1)
| Ford (0) --<< if zero list it?
| Skoda (1)
| ...
with year - all
YEAR | Select Make
Year | Acura (1)
>>2013 | Audi (1)
2012 | BMW (0) --<< if zero list it?
2011 | Cadillac (0)
2010 | Crysler (0)
| ...
with year - matched
YEAR | Select Make
Year | Acura (1)
>>2013 | Audi (1)
2012 | Skoda (1)
2011 |
2010 |
ASKER
select make + '('+ convert(varchar(30), sum(case when (@year is null or year = @year) then 1 else 0 end)) + ')' from vehiclemodelyear
group by make
The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications
TRUSTED BY
Ask yourself this--
Do you want one result row for each kind of car, or do you want a result row for each matching vehicle?
If you want summarized data, then you run the first query. If you want other data, run the second query.
If you know exactly what question you are asking, try posting some sample data or put it in an sqlfiddle and we can help you compose an appropriate query.