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

Thread: SQL Help..

  1. #1
    Join Date
    Jan 2003
    Location
    Hull, UK
    Posts
    220

    SQL Help..

    Hi,

    I got a group table.

    the data in table is

    group_id,date,timeframe,available,free

    ex.

    groupid date t/f avl free
    100 20/2 1 5 5
    100 20/2 2 4 4
    100 20/2 3 2 1

    110 20/2 1 3 3
    110 20/2 2 4 4
    110 20/2 3 5 5

    i need the output like this

    100 20/2 1 8 8
    100 20/2 2 8 8
    100 20/2 3 7 6


    i need to sum up the available column and free column (merging 110 groupid into 100)


    Any help appreciated.

    Thanks

    SS

  2. #2
    Join Date
    Feb 2004
    Posts
    77
    select a.group_id, a.date, a.timeframe,
    a.avl + b.avl, a.free + b.free
    from (select group_id, date, timeframe, avl, free
    from ur_table
    where group_id = 100) a,
    (select group_id, date, timeframe, avl, free
    from ur_table
    where group_id = 110) b
    where a.date = b.date
    and a.timeframe = b.timeframe;

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