Results 1 to 4 of 4

Thread: How to do?

  1. #1
    Join Date
    Oct 2006
    Posts
    9

    Unanswered: How to do?

    Hello all!

    I have a table called w like this:

    PRJNO SRLNO ACTWV ACTMH
    4052 F 1.0000 0.250
    4054 G 1.0000 0.250
    4054 W 1.0000 0.250
    4054 F 1.0000 2.200
    4054 G 1.0000 2.200
    4054 F 1.0000 0.220

    and after i run a query the result to be:

    prjno [sum of ACTWV] [sum of ACTMH]
    4052 1.0000 0.250
    4054 2.0000 5.120

    I tried to write a qurey:

    SELECT DISTINCTROW W.PRJNO, Sum(W.ACTMH) AS [Sum Of ACTMH], Sum(w.ACTWV) AS [Sum Of ACTWV]
    FROM W
    GROUP BY W.PRJNO;


    but it is enough for me. In Sum(w.ACTWV) i want to put one condition to select only SRLNO='F' but i didn't succed till now. In Oracle/sql exist DECODE command but in access i didn't found any solution.

    Can anybody help me?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    SELECT PRJNO
         , Sum( IIF(SRLNO='F', ACTMH, 0)  ) AS [Sum Of ACTMH]
         , Sum( ACTWV )                     AS [Sum Of ACTWV]
      FROM W
    GROUP 
        BY PRJNO
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Sum(IIF (SRLNO='F' ,ACTMH,0))

    Next question ...

    DAMN!!! Rudy got it 1st ...
    Back to Access ... ADO is not the way to go for speed ...

  4. #4
    Join Date
    Oct 2006
    Posts
    9
    Thanks a lot!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •