求一SQL语句
原数据
商品 原价 打折方式1 折扣1 打折方式2 折扣2
笔记本 10000 NULL 0 NULL 0
电视机 2000 促销 200 NULL 0
冰箱 3000 促销 300 老客户 400
要得出结果
商品 打折方式 价钱
笔记本 NULL 10000
电视机 促销 2000
电视剧 促销 -200
冰箱 促销 3000
冰箱 促销 -300
冰箱 老客户 -400
需求的比较奇怪。
大概来说,每个有效的折扣,都另外起一行,并使用负数表示
实现起来比较奇怪,加分
union all
SQL code:
select 商品 as 商品 ,打折方式1 as 打折方式,原价 as 价钱 from 表
union all
select 商品,-打折方式1,折扣1 from 表
union all
select 商品,-打折方式2,折扣2 from 表
union all
相关问答:
with adod_dict do
begin
close;
commandtext:='select bgqxcode,count(*) wjsl from wscl_wsda_file where wjnd=:tnd group by bgqxcode'; ......
sql2005
select *from v_ddxx where d_sfsc='0' and (g_ssbm='1001' or g_ssbm='1002') and (xxf>0 and xxfwzf <>0 ),执行速度慢的要死,但是如果把(xxf>0 and ......
大家帮忙看看这2个sql语句哪个查询的速度更快点。谢谢帮忙。比较着急。在做性能测试。
select * from
表A LEFT OUTER JOIN 表B ON (表A.id || ' ' =表B.id) ,表C , 表D, 表E
Where其他条件
select * ......
access 中执行sql update语句时有时候成功有时候不成功,但是access中不出错误信息,不知道是什么原因,有哪位大侠知道,请帮忙啊
贴SQL语句,检查表、字段的有效性设置
sql 在查询分析器里面 执行很正常
是 ......