DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: woeful programming skills - help?

  1. #1
    Join Date
    Dec 1999
    Location
    Purgatory
    Posts
    346

    woeful programming skills - help?

    Hi,

    I'm trying to get the rowcount from two tables where the key matches. This works fine. But then I also want to get the rowcount from the first table.

    The code works if I take out the -- commented line.

    Can't get this to work... Help!!


    Code:
    select COUNT(*) "KEY MATCH"
    --      ,c.firstcount
    from  TMP_JP_W_CARD_TRANSACTION a
               ,W_CARD_TRANSACTION b
               ,(select count(*) firstcount 
                 from TMP_JP_W_CARD_TRANSACTION) c
    where a.ACCOUNT_ORG = b.ACCOUNT_ORG
    
    SQL>
          ,c.firstcount
           *
    ERROR at line 2:
    ORA-00937: not a single-group group function

  2. #2
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    I'm not sure what you're trying to do, but if you put
    GROUP BY c.firstcount
    as the last line, the error will go away (might not give you what you want but . . . )

    HANG ON ! ! ! !
    that's a Cartesian product . . . . can't be right . . . no condition on "table" c

  3. #3
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    Is this what you want:
    Code:
    select * from  
    (select count(*) firstcount, ACCOUNT_ORG 
     from   TMP_JP_W_CARD_TRANSACTION
     group by ACCOUNT_ORG) a,
    (select count(*) firstcount, ACCOUNT_ORG 
     from   TMP_CARD_TRANSACTION
     group by ACCOUNT_ORG) b
    where a.ACCOUNT_ORG = b.ACCOUNT_ORG

  4. #4
    Join Date
    Dec 1999
    Location
    Purgatory
    Posts
    346
    Yes! You're right about the cartesian. Good job it didn't work, I still be here waiting for the results......

    What I'm trying to do:-

    I have 2 tables, TableA A and TableB B. I require output as follows..

    [RowCount where A.key = B.key],[RowCount of A],[RowCount of B]

    It's part of a reconciliation script I've been lumbered with, and ideally needs to be in a single sql statement.

  5. #5
    Join Date
    Jan 2004
    Posts
    162
    (see post in duplicate thread)
    Last edited by padders; 02-15-2005 at 09:08 AM.

Posting Permissions

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


Click Here to Expand Forum to Full Width