Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Combining two SQL Statements

Re: Combining two SQL Statements

From: Daniel Morgan <damorgan_at_x.washington.edu>
Date: Thu, 07 Oct 2004 08:21:00 -0700
Message-ID: <1097162543.282252@yasure>


agis wrote:

> "Michael" <gonnot_at_gmx.de> wrote in message
> news:89cf72b0.0410070017.26d34736_at_posting.google.com...
> 

>>Hello,
>>I need to combine this two SQL-Statements to one SQL:
>>
>>1. select UserId, UsedSlots from user_used_slots;
>>
>>UserId UsedSlots
>> a 3
>> b 5
>> a 4
>> c 3
>> b 5
>>
>>2. select UserId, FreeSlots from user_free_slots;
>>
>>UserId FreeSlots
>> a 4
>> b 5
>> b 3
>> c 3
>> b 5
>>
>>==> The resulting SQL-Staetement should show something like this:
>>(TotalSlots = UsedSlots + FreeSlots)
>>
>>UserId UsedSlots FreeSlots TotalSlots
>> a 7 4 11
>> b 10 15 25
>> c 3 3 6
>>
>>How can I produce a Output which calculates everything correctly??
>>Thanks,
>>Michael
> 
> 
> select a.userid,a.usedslots,b.freeslots,(a.usedslots+b.freeslots) totalslots
> from user_used_slots a,user_free_slots b
> where a.userid=b.userid

Please do not give students answers for their homework ... they don't learn anything when it is handed to them on a silver platter: Hints are ok but please not completed answers.

Thanks.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace 'x' with 'u' to respond)
Received on Thu Oct 07 2004 - 10:21:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US