本帖最后由 evangoe 于 2013-09-23 10:14:29 编辑

解决方案 »

  1.   


    结果集,表一是结果集,表二是想将表一处理后的到的结果。可以用sql,可以用java,设置可用excel,只要能将表一能够转换为表二的样式就OK了。
      

  2.   

    如果物是固定的话,我知道怎么写,要是物是变化,不知道有多少的时候 我就不会了select  t.shop,sum(t.show1) '1',sum(t.show2) '2',sum(t.show3) '3',sum(t.show4) '4'  from (select g.shop,case  when g.good= 1  then sum(g.sum)  else 0 end show1,
    case  when g.good= 2  then sum(g.sum)  else 0 end show2,
    case  when g.good= 3  then sum(g.sum)  else 0 end show3,
    case  when g.good= 4  then sum(g.sum)  else 0 end show4
    from good_inf  as g group by g.shop,g.good) t group by t.shop
      

  3.   

    还是用java写吧
    step1 先查出物(对应第一行多少列)
    step2 再根据物查出对应的每个店的数量