表:
name,date,money,tex
求语句:
把所有列全部列出来,然后再最后加上一行money的总计谁会??我写了半天除了总计之外还多了一行按date的每天小计...郁闷

解决方案 »

  1.   

    最后加上一行money的总计。
    这里的最后一行,只是返回结果集里所有记录的money合计?
      

  2.   

    没看懂你的需求,这样么
    select name,date,money,tex from 表
    union all
    select 1,1,sum(money),1 from 表
      

  3.   

    select name,date,money,tex from t
    union all
    select null,null,sum(money),null from t
      

  4.   

    select name,date,money,tex,sum(money) over(partition by name) from table
    其中name 代表唯一主键
      

  5.   

    select t.name,t.date,t.money,t.tex,x.sum_money from t 
    left join 
    (select date,sum(money) from t group by date) x
    on 
    x.date=t.date
      

  6.   

    select name,date,tex,sum(money) over(partition by name order by date) as money
    from tb
      

  7.   

    select name,date,money,tex from vote
    union 
    select null,null,sum(money),null from vote
      

  8.   

    这样就能行啊
    要不这样也行With t As(
    Select '11' Name,'20100101' Date1,10 money From dual
    Union All
    Select '12','20100102' ,10  From dual
    Union All
    Select '13' ,'20100103' ,10  From dual
    Union All
    Select '14' ,'20100103' ,10  From dual
    Union All
    Select '15' ,'20100104' ,10  From dual
    Union All
    Select '15' ,'20100105' ,10  From dual

    Select Name,Date1,Sum(money) c
    From t
    Group By Rollup(Name,Date1)
    Having Grouping(Name) = Grouping(date1)
      

  9.   

    selct 
    name,date,money,tex ,money_total from
    (select name,date,money,tex  from table1) a,
    (select sum(money) as money_total  from  table1) b
      

  10.   

    select name,date,money,tex from tablename
    union 
    select null,null,sum(money),null from tablename 
      

  11.   

    select name,date,money,tex from tablename
    union  
    select null,null,sum(money),null from tablename