Forum Replies Created

Viewing 10 posts - 1 through 10 (of 10 total)

  • RE: Help with aggregate function

    Drew thank you very much for your help. Really apreciated. I just had to test all the possible data scenarios. My real table has more than 160 million records. However...

  • RE: Help with aggregate function

    my apologies for the name confusion J. Drew.

  • RE: Help with aggregate function

    I will check that part Jeff. I was checking all the possible scenarios and I think the query does not work for the following set of data:
    create table VALUATION...

  • RE: Help with aggregate function

    Awesome Jeff!!.  Thanks a lot. I think the following query is also rdbms agnostic:
    with newtab (col1,col2, mtm)
    as
    (SELECT upper(col1), upper(col2), mtm FROM sampledata
      WHERE upper(col1) <...

  • RE: Help with aggregate function

    Really sorry but business keep changing the requirements. My table is:
    create table SampleData ( col1 VARCHAR(10), col2 VARCHAR(10), MTM numeric(10));
    INSERT INTO SampleData VALUES
    ('A','B',100),
    ('B','A',-50),
    ('A','C',200),
    ('A','D',100),
    ('A','B',150),

  • RE: Help with aggregate function

    unfortunately taht query did not encompass all scenarios such as:
    col1 col2 col3
    ('A','B',100),
    ('B','A',-50),
    ('A','C',200),
    ('A','D',100),
    ('A','B',150),
    ('B','F',200),
    ('d','K',400),
    ('K','D',-20),
    ('C','D',-50),
    ('D','C',-60);
    I need to display which one of...

  • RE: Help with aggregate function

    Following query produced the expected results:
    A    B    300
    A    C    200
    A    D    100
    B    F    200
    D    C    50

    SELECT CASE WHEN COL1 <= COL2 AND COL3 > 0 THEN COL1 ELSE COL2 END AS COL1,
     CASE...

  • RE: Help with aggregate function

    Sorry . that was only half of the work I had to do. tuens out that every time I have negative value in col3 I have to turn col3 positive...

  • RE: Help with aggregate function

    That is excellent guys. Both queries work as expected. I have modified the query a little bit to accomodate a case when col3 is negative. In that case it means...

  • RE: Help with aggregate function

    col1 and col2 represent company names and col3 is the transaction value, could be negative, between the companies. So I want to know how much company A spent?

Viewing 10 posts - 1 through 10 (of 10 total)