Sum of a Sum

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • patwilly
    New Member
    • Nov 2008
    • 1

    Sum of a Sum

    Hi ,

    I would like to sum a sum from a query. That is the code:

    Code:
     SELECT distinct ps.v_sbkuerzel as Worker , sl.v_bezeichnung as Activities, sum  (  m.n_betr_ho)    as sum  from mbu_bks m,stamm_lookup sl,akte_akte a,pers_sbkonto ps 
    where m.c_sh = 'H' and a.i_mana_lookup_id = sl.i_stamm_lookup_id and a.i_akte_akte_id = m.i_akte_akte_id and m.n_betr_ho > 0
     group by sl.v_bezeichnung,ps.v_sbkuerzel
    and I got this result:





    Code:
    Worker    |        Activities                              |     sum     | 
    
    
     AK          | Allgemeiner Beratervertrag       |  111817.72000 |
     AK          | Allgemeines Strafrecht              |  130709.18000 |
     AK          | Allgemeines Verwaltungsrecht   |  347670.89000 |
     AK          | Allgemeines Zivilrecht                | 2173736.60000 |
     AK          | Arbeitsrecht                                |  342461.77000 |
     AK          | Arzthaftungsrecht                       |   17221.75000 |
     AK          | Beratung                                     |   12202.54000 |
     AK          | Familienrecht                               |  986569.08000 |
     AK          | Gesellschaftsrecht                       |   80015.81000 |
     AK          | Mahnverfahren                             |    2293.90000 |
     AK          | Mietrecht                                      |  281625.12000 |
     AK          | Öffentlicher Dienst                           |    3410.40000 |
     AK          | Öffentliches Baurecht        |   21116.97000 |
     AK          | Ordnungswidrigkeit           |   24329.13000 |
     AK          | Privates Baurecht            |   32687.97000 |
     AK          | Sozialrecht                  |  354771.20000 |
     AK          | Steuerberatung allgemein     |    4539.85000 |
     AK          | Steuerrecht                  |   36872.15000 |
     AK          | Steuerstrafrecht             |    1228.15000 |
     AK          | Strafvollstreckung           |   10079.30000 |
     AK          | Unfallschadenregul.          |    5335.40000 |
     AK          | Verkehrssachen               |   11199.72000 |
     AK          | WEG                          |    3900.75000 |
     AK          | Zwangsvollstreckung          |   25380.81000 |
     H           | Allgemeiner Beratervertrag   |  239609.40000 |
     H           | Allgemeines Strafrecht       |  280091.10000 |
     H           | Allgemeines Verwaltungsrecht |  745009.05000 |
     H           | Allgemeines Zivilrecht       | 4658007.00000 |
     H           | Arbeitsrecht                 |  733846.65000 |
     H           | Arzthaftungsrecht            |   36903.75000 |
     H           | Beratung                     |   26148.30000 |
     H           | Familienrecht                | 2114076.60000 |
     H           | Gesellschaftsrecht           |  171462.45000 |
     H           | Mahnverfahren                |    4915.50000 |
     H           | Mietrecht                           |  603482.40000 |
     H           | Öffentlicher Dienst             |    7308.00000 |
     H           | Öffentliches Baurecht        |   45250.65000 |
     H           | Ordnungswidrigkeit           |   52133.85000 |
     H           | Privates Baurecht              |   70045.65000 |
     H           | Sozialrecht                          |  760224.00000 |
     H           | Steuerberatung allgemein     |    9728.25000 |
     H           | Steuerrecht                          |   79011.75000 |
     H           | Steuerstrafrecht             |    2631.75000 |
     H           | Strafvollstreckung           |   21598.50000 |
     H           | Unfallschadenregul.          |   11433.00000 |
     H           | Verkehrssachen               |   23999.40000 |
     H           | WEG                                    |    8358.75000 |
     H           | Zwangsvollstreckung          |   54387.45000 |
     KM          | Allgemeiner Beratervertrag   |  111817.72000 |
     KM          | Allgemeines Strafrecht       |  130709.18000 |

    Now I would like to know , the total amount of each Worker regardless of the activities . Can someone help ??
    Last edited by eWish; Nov 20 '08, 11:15 PM. Reason: Please use the code tags
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    You can do a select from a select statement (not only from a physical table)

    Comment

    • gochengz
      New Member
      • Nov 2008
      • 1

      #3
      how about this one sql broo ... you just remove the activity in field n group by ...

      SELECT ps.v_sbkuerzel as Worker , sum ( m.n_betr_ho) as sum
      from mbu_bks m,stamm_lookup sl,akte_akte a,pers_sbkonto ps
      where m.c_sh = 'H' and a.i_mana_lookup _id = sl.i_stamm_look up_id and a.i_akte_akte_i d = m.i_akte_akte_i d and m.n_betr_ho > 0
      group by ps.v_sbkuerzel

      Comment

      Working...