select * from (
select *
from table1
where xxx in (select xxx from tableA where...))
union
select *
from table1
where xxx in (select xxx from tableB where...))
) group by comon的前三个字符(comon是从table1里面的一个字段,这个字段是六位,前三位表示省后三位表示市,按省分下组 例如001002表示浙江杭州)
要求 : 取出table1里面的所有数据,按照省分组显示请教了
select *
from table1
where xxx in (select xxx from tableA where...))
union
select *
from table1
where xxx in (select xxx from tableB where...))
) group by comon的前三个字符(comon是从table1里面的一个字段,这个字段是六位,前三位表示省后三位表示市,按省分下组 例如001002表示浙江杭州)
要求 : 取出table1里面的所有数据,按照省分组显示请教了
from (
select *
from table1
where xxx in (select xxx from tableA where...))
union
select *
from table1
where xxx in (select xxx from tableB where...))
) group by substring(comon,1,3)
(
select *
from table1
where xxx in (select xxx from tableA where...)
union
select *
from table1
where xxx in (select xxx from tableB where...)
) t
group by substr(comon,1,3)
题目有点问题,要取出table1里面的所有数据,又按照省分组显示,没给出各个字段的取数规则,貌似很难实现