Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2011

    Unanswered: SQL Unique Query

    Im not sure if this the right forum but:

    I have a data output with many rows. In order to group things with flags, I do this in excel using 2 formulas which *** a flag of 0 or 1 in 2 new columns.

    This takes a long long time as I have hundreds of thousands of rows and wondered of I could do it in sql?

    Its transact SQL and the formulas I use in excel are:

    =IF(SUMPRODUCT(($A$2:$A2=A2)*($B$2:$B2=B2)*($C$2:$ C2>=C2-1/24)*($C$2:$C2< C2+1/24))> 1,0,1)


    Any idea how I can do this in sql??

    The columns above do not relate to the actual columns I use, just an example.

  2. #2
    Join Date
    May 2005
    South Africa
    Provided Answers: 1
    Looks like you need something similar to a running total - I think best is not to do this in an sql query.

  3. #3
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    It does look like a running total, and if the version of Sybase server you are using provides Windowing Aggregate Functions, those will do exactly what you are trying to do.

    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Posting Permissions

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