各位大哥:
有如下数据结构:
code brand name quant ordernum createTime did type
750 联想 联想-TD80t-黑 73 1 2011-09-01 1 001
750 联想 联想-TD80t-黑 73 1 2011-09-06 1 001
请问如何合并成如下一条数据 (其中日期(createTime)为动态的)code type brand name quant 2011-09-01 2011-09-06 did
750 001 联想 联想-TD80t-黑 73 1 1 1
其中2011-09-01下对应的1为ordernum的值(2011-09-06雷同)
有如下数据结构:
code brand name quant ordernum createTime did type
750 联想 联想-TD80t-黑 73 1 2011-09-01 1 001
750 联想 联想-TD80t-黑 73 1 2011-09-06 1 001
请问如何合并成如下一条数据 (其中日期(createTime)为动态的)code type brand name quant 2011-09-01 2011-09-06 did
750 001 联想 联想-TD80t-黑 73 1 1 1
其中2011-09-01下对应的1为ordernum的值(2011-09-06雷同)
max(decode(createTime,'2011-09-01',ordernum,0)) as 2009-09-01,
max(decode(createTime,'2011-09-06',ordernum,0)) as 2009-09-06,
did,type
from tab
group by code,brand,name,quant,did,type
max(decode(createTime,to_date('2011-09-01','YYYY-MM-DD'),ordernum,0)) as 2009-09-01,
max(decode(createTime,to_date('2011-09-01','YYYY-MM-DD'),ordernum,0)) as 2009-09-06,
did,type
from tab
group by code,brand,name,quant,did,type