Home » SQL & PL/SQL » SQL & PL/SQL » get data from two tables
get data from two tables [message #636093] Thu, 16 April 2015 13:54 Go to next message
ketangarg86
Messages: 3
Registered: March 2015
Junior Member
Hi,

I am relatively new to Oracle SQL and have a small project. I need to do the below:
1. Get the distinct email address that are sending orders
2. Sender name
3. Vendor name
4. Count of orders by that email address
5. Whether the email address is from the preferred vendor (I have a predefined list, Apple and RBS are the preferred vendors in this case).

I would really appreciate if you could please help me out. Below are the sample tables.

Table 1
Email Id Sender Orders Source Id
123@APPLE.COM Jon 10 1
345@YAHOO.COM Ron 15 2
123@APPLE.COM Jon 10 1
234@IBM.COM Pete 15 3
234@GOOGLE.COM Peter 10 4
345@GOOGLE.COM Aaron 15 4
111@FACEBOOK.COMMike 25 5
222@TCS.COM Michael 20 6
665@RBS.COM Ming 11 7
345@UBS.COM Ping 15 8
567@UBS.COM Sing 60 8

Table 2
ID Source Name
1 Apple
2 Yahoo
3 IBM
4 Google
5 Facebook
6 TCS
7 RBS
8 UBS

Result
Email id Sender Source Name Count Orders Is In list
123@apple.com Jon Apple 20 Yes
345@YAHOO.COM Ron Yahoo 15 No
234@GOOGLE.COM Peter Google 10 No
and so on

Re: get data from two tables [message #636094 is a reply to message #636093] Thu, 16 April 2015 13:59 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
http://www.orafaq.com/forum/mv/msg/196730/634654/#msg_634654
Re: get data from two tables [message #636097 is a reply to message #636093] Thu, 16 April 2015 14:54 Go to previous message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Also always post your Oracle version, with 4 decimals.

With any SQL or PL/SQL question, please, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.
Previous Topic: Need to know about some basic for explain plan
Next Topic: MAT view - Start with & Next
Goto Forum:
  


Current Time: Fri Apr 19 18:09:37 CDT 2024