insert 报价表 (公司名称,价格,产品) select 公司名称,价格,产品 from 定价表 where 公司名称='大发公司' union all select 公司名称,价格,产品 from 定价表 where 产品 not in (select 产品 from 定价表 where 公司名称='大发公司')
insert 报价表 (公司名称,价格,产品) select 公司名称,价格,产品 from 定价表 where 公司名称='大发公司' union all select 公司名称,价格,产品 from 定价表 where 公司名称='全部' and 产品 not in (select 产品 from 定价表 where 公司名称='大发公司')或:insert 报价表 (公司名称,价格,产品) select 公司名称,价格,产品 from 定价表 where 公司名称='大发公司' or (公司名称='全部' and 产品 not in (select 产品 from 定价表 where 公司名称='大发公司'))
select a.* into 报价表 from 定价表 a join (select min(公司名称) as 公司,产品 from 定价表 group by 产品 where 产品 in ('大发公司','全部') ) T on a.产品=T.产品 and a.公司名称=T.公司
上面错了,报价表已有了:insert into 报价表 select a.* from 定价表 a join (select min(公司名称) as 公司,产品 from 定价表 group by 产品 where 产品 in ('大发公司','全部') ) T on a.产品=T.产品 and a.公司名称=T.公司
select 公司名称,价格,产品 from 定价表 where 公司名称='大发公司'
union all
select 公司名称,价格,产品 from 定价表 where 产品 not in (select 产品 from 定价表 where 公司名称='大发公司')
select 公司名称,价格,产品 from 定价表 where 公司名称='大发公司'
union all
select 公司名称,价格,产品 from 定价表 where 公司名称='全部' and 产品 not in (select 产品 from 定价表 where 公司名称='大发公司')或:insert 报价表 (公司名称,价格,产品)
select 公司名称,价格,产品 from 定价表 where 公司名称='大发公司' or (公司名称='全部' and 产品 not in (select 产品 from 定价表 where 公司名称='大发公司'))
into 报价表
from 定价表 a join
(select min(公司名称) as 公司,产品
from 定价表
group by 产品
where 产品 in ('大发公司','全部')
) T on a.产品=T.产品 and a.公司名称=T.公司
select a.*
from 定价表 a join
(select min(公司名称) as 公司,产品
from 定价表
group by 产品
where 产品 in ('大发公司','全部')
) T on a.产品=T.产品 and a.公司名称=T.公司