Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2011
    Posts
    2

    Lightbulb Unanswered: Calculations in select statement

    Hello all!
    I try calculated total of Units.
    In first placed my select statement was
    select *
    , sum(cast(UNITS as INT)) over (partition by b_alt_id order by person, dos_dt )AS TOT_UOS
    from Report4_results.
    But in SQL partition by order by is not work.

    I looking for calculation:

    Person, Serv Dt, Unit, Total
    001 ,1/10/2001, 1, 1
    001 ,1/11/2001, 1, 2
    001 ,1/16/2001, 5, 7

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    is not work is not a valid SQL error message

    And please make sure your SQL statements are formatted using the [code] tag

  3. #3
    Join Date
    Jan 2011
    Posts
    2

    SQL Statment issue

    How I can do SQL statements are formatted using the [code] tag?

  4. #4
    Join Date
    Nov 2004
    Posts
    1,427
    Provided Answers: 4
    How I can do SQL statements are formatted using the [code] tag?
    By enclosing your SQL code between [CODE] and [ /CODE] (but written without a space before the "/").

    I think this will work for you.
    Code:
    SELECT Person, 
    	Serv_Dt, 
    	Unit,
    	sum(cast(UNITS as INT)) AS Total
    from Report4_results
    GROUP BY Person, Serv_Dt, Unit
    With kind regards . . . . . SQL Server 2000/2005/2012
    Wim

    Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
    Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages

Posting Permissions

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