日期:2014-05-17 浏览次数:20412 次
CREATE TABLE TBA
(
id int,
type nvarchar(50),
proname nvarchar(50)
)
INSERT INTO TBA
select '1','上海大众','POLO' union all
select '2','上海大众','桑塔纳2000' union all
select '3','一汽大众','捷达' union all
select '4','一汽大众','CC' union all
select '5','别克','凯越'
select type,count(type) from TBA group by type
select type ,count(1) as '数量'
from tb
group by type
if OBJECT_ID('car') is not null
drop table car
create table car
(
ID int,
type nvarchar(20),
proname nvarchar(20)
)
go
insert into car
select 1,'上海大众','POLO' union all
select 2,'上海大众','桑塔纳2000' union all
select 3,'一汽大众','捷达' union all
select 4,'一汽大众','CC' union all
select 5,'别克',' 凯越'
select type,COUNT(type) from car
group by type
order by type desc