第二种方法主要是注意CASE的使用
select field1, field2, ...fieldn,
GroupId =
CASE
WHEN style=200 THEN 0
WHEN style=100 THEN 1
WHEN style=300 THEN 2
END
order by GroupId, field1, field2
or
select field1, field2, ...fieldn,
CASE style
WHEN 200 THEN 0
WHEN 100 THEN 1
WHEN 300 THEN 2
END
order by style, field1, field2
建立3个视图啊
按Style的值;
create view v1 as select * from table1 where Style=200;
create view v2 as select * from table1 where Style=100;
create view v3 as select * from table1 where Style=300;
select * from v1 ,v2,v3 where v1.id=v2.id(+) and v2.id=v3.id(+) order by v1.id,v2.id,v3.id;
其它的你自己组和吧,
用视图可以搞定的,你自己在想想