Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2004
    Posts
    46

    Unanswered: Basic SQL question

    Hi All !

    I have a Basic Question,
    Can i do following Statements in a single SQL statment

    1) select count(*) as recordcount,sum(amt) as total amount from table
    2) select count(*) as recordcount,sum(amt) as total amount from table_exception
    3) I need to add both the values respectively from statment 1 and 2 and get the result .

    Hope I am clear

    Thanks
    Mark.

  2. #2
    Join Date
    Jun 2004
    Posts
    46
    I got it worked...like this

    select count(*)+(select count(*) from table),sum(tot_invc_amt)+(select sum(amt) from table_exception) from table

    Thanks
    Mark.

  3. #3
    Join Date
    Aug 2004
    Posts
    330
    select sum(recordcount), sum(total)
    from
    (select count(*) as recordcount,sum(amt) as total amount from table
    union all
    select count(*) as recordcount,sum(amt) as total amount from table_exception)

Posting Permissions

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