现有一张表。表结构如下:  表1 日期, 性质,品种,数量,特征
 
  要如下效果:
  
   日期         性质1            性质2           性质3
      品种 数量 特征   品种 数量 特征   品种 数量 特征    
 2002-1-1    A    11   无    B    22   无     C   33   无
    .
    .
    .
如何做? 在线等待.

解决方案 »

  1.   

    to  cnhgj(黄桂佳) :
       能不能说的具体点.
      

  2.   

    select a.日期,b.品种,b.数量,b.特征,c.品种,c.数量,c.特征,d.品种,d.数量,d.特征
    from
    (select dinstinct 日期 from table order by 日期) a,
    (select 日期, 品种, sum(数量) as 数量,特征
    from table 
    where 性质='性质1'
    group by 日期, 品种,特征) b,
    (select 日期, 品种, sum(数量) as 数量,特征
    from table 
    where 性质='性质2'
    group by 日期, 品种,特征) c,
    (select 日期, 品种, sum(数量) as 数量,特征
    from table 
    where 性质='性质3'
    group by 日期, 品种,特征) d
    where a.日期*=b.日期
     and a.日期*=c.日期
     and a.日期*=d.日期