Results 1 to 2 of 2

Thread: Union Clause

  1. #1
    Join Date
    Apr 2004

    Question Unanswered: Union Clause

    I have to summarize the columns that are returned from a UNION ALL
    in a cursor .

    I tried to treat the resultant UNION ALL as a table and do the grouping but didn't work

    Can anyone give me a hint ?

  2. #2
    Join Date
    Jan 2003
    Provided Answers: 5
    Something like this maybe:

    with temp1 as (
    select col1,col2 from mytable1
    union all
    select col1,col2 from mytable2
    ) select count(*),sum(col1),avg(col2) from temp1


Posting Permissions

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