求SQL查询语句
sql吧
全部回复
仅看楼主
level 1
sdwfwcm 楼主
表结构:
ID 日期 品名 价格
1 2011-12-01 主机 1800.00
2 2011-12-01 显示器 1000.00
3 2011-12-02 主机 1750.00
4 2011-12-02 显示器 1050.00
5 2011-12-03 主机 1780.00
6 2011-12-04 显示器 1080.00
只有主机 显示器两种商品,每天对外报价,如何选择每天两种商品都有报价的记录,
如上表 只选择12月01日 12月02日的记录 不选择12月03日 12月04日的记录
2012年01月18日 08点01分 1
level 1
按日期分组统计吧
2012年01月20日 05点01分 2
level 5
嗯 要分组做
2012年02月03日 02点02分 3
level 2
我感觉应该用UNION:
select table_new.日期,table_new.pm1,table_new.pm2,table_new.价格 from
(SELECT "日期","品名" as pm1,null,"价格" from table where "品名"="主机"
union SELECT "日期",null,"品名" as pm2,"价格" from table where "品名"="显示器")as table_new
where table_new.pm1 is not null and table_new.pm2 is not null

2012年02月04日 16点02分 4
1