outer join when there are several tables are involved

Could not put up the question correctly to the last channel, my problem is with the join when there are several tables are involved, this is just one example of the task that I have to carry.

Tab1 aura model id retailer_id information for all the weeks (from the first Monday) of the month of JUNE with cost and Helen

Tab1

model_id

retailer_id

sell_date

cost

Helene

1

12

June 3, 13

100

40

1

12

June 10, 13

200

20

1

12

17 June 13

300

20

1

12

24 June 13

400

20

2

12

June 3, 13

300

10

2

12

June 10, 13

200

20

2

12

17 June 13

300

20

2

12

24 June 13

400

20

Tab2:

each retailer belongs to a dealer, under the table has the same information

retailer_id

Dealer_id

12

100

13

100

14

101

15

101

16

101

Tab 3

There is a third layer where each dealership is having a garage band

Dealer_id

Dealer_group

100

1001

101

1001

102

2001

103

2001

104

3001

105

3001

Tab4:

Of this table for each model and dealer discount information for the month of June (every week)

model_id

Dealer_group

discount_date

discount

1

1001

June 3, 13

10

1

1001

June 10, 13

20

1

1001

17 June 13

10

1

1001

24 June 13

30

2

1001

June 3, 13

10

2

1001

June 10, 13

20

2

1001

17 June 13

10

2

1001

24 June 13

30

3

2001

June 3, 13

10

3

2001

June 10, 13

20

3

2001

17 June 13

10

3

2001

24 June 13

30

Master_info:

It's the main table which is the master table for model /retailer information

Model_id

retailer_id

1

12

2

12

3

12

4

12

1

13

2

13

Output

model_id

retailer_id

sell_date

cost

Helene

Final (cost-helene-discount)

1

12

June 3, 13

100

40

50

1

12

June 10, 13

200

20

160

1

12

17 June 13

300

20

270

1

12

24 June 13

400

20

350

2

12

June 3, 13

300

10

280

2

12

June 10, 13

200

20

160

2

12

17 June 13

300

20

270

2

12

24 June 13

400

20

350

3

12

June 3, 13

0

0

0

3

12

June 10, 13

0

0

0

3

12

17 June 13

0

0

0

3

12

24 June 13

0

0

0

4

12

June 3, 13

0

0

0

4

12

June 10, 13

0

0

0

4

12

17 June 13

0

0

0

4

12

24 June 13

0

0

0

1

13

June 3, 13

0

0

0

1

13

June 10, 13

0

0

0

1

13

17 June 13

0

0

0

1

13

24 June 13

0

0

0

2

13

June 3, 13

0

0

0

2

13

June 10, 13

0

0

0

2

13

17 June 13

0

0

0

1

13

24 June 13

0

0

0

For highted above records (model_id / retailer_id combination) there is no record in tab1 but they have entered in master_info then the recordings should come for all model_id/retailer_id with all the 0 values

Hello

Thanks for posting the sample data.

It is unclear what dates you want to include in the output.  The following query shows how you can generate every Monday in a given range.  If you only want to include the dates that are actually present in tabl1 and/or tab4, you can simplify this a bit.

WITH date_range AS

(

SELECT TRUNC (TO_DATE (' 3 June 2013', 'DD-Mon-YYYY'))

, 'IW '.

) AS first_monday

, TRUNC (TO_DATE (24 June 2013 ', 'DD-Mon-YYYY') + 6)

, 'IW '.

) AS last_monday

OF the double

)

all_mondays AS

(

First_monday SELECT + (7 * (LEVEL - 1)) AS sell_date

OF date_range

CONNECT BY LEVEL<= 1="" +="" (="" (last_monday="" -="">

/ 7

)

)

SELECT mi.model_id

mi.retailer_id

am.sell_date

, Cost of NVL (t1.cost, 0) AS

, NVL (t1.rebat, 0) IN the refund

, NVL (t1.cost, 0)

-(NVL (t1.rebat, 0))

+ NVL (t4.discount, 0)

) AS final

E master_info

CROSS JOIN all_mondays am

LEFT OUTER JOIN tab1 t1 ON t1.model_id = mi.model_id

AND t1.retailer_id = mi.retailer_id

AND t1.sell_date = am.sell_date

LEFT OUTER JOIN tab2 t2 ON t2.retailer_id = mi.retailer_id

LEFT OUTER JOIN tab 3 t3 ON t3.dealer_id = t2.dealer_id

LEFT OUTER JOIN tab4 t4 ON t4.model_id = t1.model_id

AND t4.dealer_group = t3.dealer_group

AND t4.discount_date = t1.sell_date

ORDER BY mi.retailer_id

mi.model_id

am.sell_date

;

The results are not exactly what said you you wanted.  I suspect it's because of typos in that you posted.

Tags: Database

Similar Questions

  • The last time I used identifier apple of my father to the appstore on my macbook pro. (Now, I have my own apple ID). Sometimes, when there are apps that I want to update, a window would jump out to ask me to sign identifying apple of my father, but I want

    The last time I used my id to a friend for the appstore apple on my macbook pro. (Now, I have my own apple ID). Sometimes, when there are apps that I want to update, a window would jump out to ask me to connect to my apple to a friend id, but I want to update the application using my own apple ID. Is that what I have to use my apple ID to update the applications? Please help me!

    The last time I used my id to a friend for the appstore apple on my macbook pro. (Now, I have my own apple ID). Sometimes, when there are apps that I want to update, a window would jump out to ask me to connect to my apple to a friend id, but I want to update the application using my own apple ID. Is that what I have to use my apple ID to update the applications? Please help me!

  • How to hide a column in the report when there are only zeros.

    Hi Experts.,.

    Is it possible to hide a column in the report when there are only zeros.

    Thanks in advance
    Vincent

    Vincent Krishna wrote:
    Hi Experts.,.

    Is it possible to hide a column in the report when there are only zeros.

    Thanks in advance
    Vincent

    No out-of-the-box, but there are several workaround solutions if you want to continue an any of them:

    (1) use a view selector. A single report will be a pivot table with the column, the other will have the same report less column. Users can switch reports.

    (2) use a column selector. The two choices would be this column or an empty space. If white is chosen (because the user has no values), the column "will disappear" according to the report.

    (3) guided use NAV. This method involves the intervention of the user. Build a small report using the single column and put a filter "is not equal to" 0. Because there is only a single column, so all lines are 0, the report returns no rows.

    Use this report in the properties of guided navigation from one section of the dashboard. Assign to this "If the report returns lines" and put the report that contains the column in this section. Now add another article on your table edge and in the properties of guided navigation of this section, set on "If the report will return no rows" and it points to the small report as well. In this section, put a second version of your report without the column in it.

    When the column contains all zeros, the second section with column will not display in it; the first section is not displayed. When at least a line contains a value not zero, the first section is displayed with the column, and the second part will not be.

  • vRA: identity device or vSphere SSO when there are multiple vCenters (each with their own SSO) in the environment?

    The installer: We have multiple vCenters each with their own SSO. We must build a minimum install vRA lab 6.1 and used the SSO to the vCenter which is the endpoint lab (and ended up having problems when this vCenter SSO had to be rebuilt and in turn liquid reconstruction vRA). Building on a vRA 6.2 Distributed Lab (based on deployment in the 6.1 reference architecture) to validate our production plan and decided to use the identity.

    Question: For a production buildout there is no reason not to use the device of the identity (scalability, performance, lack of HA)? If you are using vSphere SSO, when there are multiple vCenters one that should be used for SSO of vRA? If that vSphere SSO is never removed (say on the whole things are replaced by a central SSO for all vCenters rather than each on their own, or some issue needs to be rebuilt) is there a clean way to repoint SSO vRA without a reconstruction?

    Post edited by: RebeccaW (removed unrelated to Postgres question)

    What I did in this case is to build a fresh cluster SSO using vCenter SSO and pointing vCAC on this one. It becomes my main source of SSO and I slowly vCenters point and other components to it overtime. You usually put vCAC SSO signed certificates and generally I find people vCenter SSO deployment in this way. To remedy this trying to modify an existing SSO vCenters and risk having to reinstall your VC because you missed the CERT, simply create a new. This also alleviates a changing overtime vCenter and spoil the vCAC SSO. The unit of identity cannot be clustered or joining existing areas of SSO. So if you are looking for HA and scale which probably does not cut it.

  • Why update when there are known bugs

    I wonder constantly up-to-date when there are bugs in it, it's not logical to me at all, this 9.0 will crash after a while because it has bugs you admitted that

    Another reason for updating, it is that each new version contains security updates that are not in the other. If you can help protect your computer with Firefox (and other software like Windows) in day.

  • Previous/next buttons in Windows 7 Media Player 12 disabled when there are videos in the playlist

    original title: Windows 7 Media Player 12 previous/next buttons disabled when there are videos in playlist works well with music files

    I have 3 computers to windows 7 that all exhibit this same problem.

    I have playlists since older versions of media center and when I play a video playlist with the previous buttons and next player will be disabled. If the playlist has audio files it next and previous buttons work fine.

    It has always worked in other versions I know that it is a feature I use all the time so I would have noticed

    Hi keith278,

    You can use Windows Media Center to play your videos.
    1. Click Start
    2. In the Search box , type Media Center
    3. Click on Media Center
    4. Select the photos + videos (you should see the library of images, Favorites, play and video library)
    5. Select the video library
    6. Cross the guests to add your video to this library folders
    7. Double-click the video file you want to play
    8. You should see the possibility of play all the
    Let us know if that helps.
  • Can I create an action to move the last page to the first?  I can only find how to manually drag the pages, and I need to make it simpler when there are a lot of pages.

    Can I create an action to move the last page to the first?  I can only find how to manually drag the pages, and I need to make it simpler when there are a lot of pages.

    Yes, you can do it using a script. This code should do the trick:

    this.movePage (this.numPages - 1, -1);

  • Is it possible to have a slide advances on its own when there are buttons on the screen?

    I wonder if there is a way to have a slide advance automatically when there are buttons on the slide, I want the eLearning course I've created for just the AutoPlay through all the slides.

    Thanks in advance!

    What do the buttons do? Just delete their point of pause and when they reach the end of the slide, and the exit action is set to continue, or go to the next slide, everything will play.

    Lilybiri

  • Exception of null on the list pointer implementing values when there are n rows in the table

    Hi Experts,

    I use JDev 11.1.1.7.

    I have a VO that I defined a LOV with no search box. In my page, I've added it as af:inputListOfValues, but when there is no rows in the table that I will meet with NPES

    < AdfcExceptionHandler > < handleException > ADFc: when Manager application exception exception handling threw a new exception.

    java.lang.NullPointerException

    at oracle.jbo.uicli.binding.JUCtrlListBinding.findOrCreateLOVDialogIteratorBinding(JUCtrlListBinding.java:5188)

    at oracle.adfinternal.view.faces.model.binding.FacesCtrlLOVBinding.getSearchBinding(FacesCtrlLOVBinding.java:204)

    to oracle.adfinternal.view.faces.model.binding.FacesCtrlLOVBinding$ ListOfValuesModelImpl.getSearchRegion (FacesCtrlLOVBinding.java:2001)

    to oracle.adfinternal.view.faces.model.binding.FacesCtrlLOVBinding$ ListOfValuesModelImpl.getQueryModel (FacesCtrlLOVBinding.java:1612)

    to oracle.adfinternal.view.faces.renderkit.rich.SimpleInputListOfValuesRendererBase$ InternalLaunchPopupListener.processLaunch (SimpleInputListOfValuesRendererBase.java:1560)

    at oracle.adf.view.rich.event.LaunchPopupEvent.processListener(LaunchPopupEvent.java:108)

    Excerpt from JSFF:

    < af:inputListOfValues id = "xxx" popupTitle = "" search and select: XXX ""

    simple value = "#{pageFlowScope.SearchBean.xxx}" = 'true' "

    model = ' #{bindings. " XXXLOV.listOfValuesModel} "columns ="30"

    searchDesc = "Select XXX" >

    < / af:inputListOfValues >

    PageDef:

    < listOfValues StaticList = 'false' use = "LOV_XXX".

    IterBinding = "XXXIterator".

    ID = "XXXLOV" / >

    Is - this bug?

    Surprisingly, it works very well if there are lines in the table that the VO is querying.

    -Soham

    Soham,

    I think you just create this LOV page by simply moving the VO, right?

    You can select the box to tick 'Include no. Selection' in your VO, and see if that helps?

    See you soon

    AJ

  • How to manage when there are huge files in the batch program?

    Hi all
    There are huge files in my lot, and when I run the batch, the performance was very poor, then, how I divide it into several small batches to improve performance?

    The solution below will work for single batch processing thread. With these lines, I was able to download 300 K Recoreds in ciustom table in 7 min.

    int i = 0;
    Read all the records in the input file
    While (not null (record = {readRecord()))}

    i ++ ;
    If (I % 500 == 0) {}

    ((FrameworkSession) SessionHolder.getSession ()) .getHibernateSession () .flush ();
    ((FrameworkSession) SessionHolder.getSession ()) .getHibernateSession () .clear ();
    }

    Process record
    } / / End then that

  • Whenever I go out my computer there are updates to install

    When I shut down the computer, it is a symbol of update on the sleep button.  I would be careful, there are so many updates every day, or should I just let it update?

    If this symbol is there every day, check your update on Windows Update history. An update may fail to install and be retried repeatedly.

    Updates Microsoft security release the second Tuesday of each month at 10:00 am Pacific time. Non-security updates are published on the fourth Tuesday of each month. Update definitions for Windows Defender and Microsoft Security Essentials also appears in the history of the update. There are no updates normally more than one or two a month out of this cycle.

  • ORA-01555: snapshot too old when there are expired blocks

    BANNER

    ----------------------------------------------------------------

    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - production

    PL/SQL Release 10.2.0.4.0 - Production

    CORE 10.2.0.4.0 Production

    AMT for Linux: release 10.2.0.4.0 - Production

    NLSRTL Version 10.2.0.4.0 - Production

    We set the size cancellation tablspace to 2 GB with undo_retention duration of 1 hour.

    We get ORA-01555: snapshot too old: rollback segment number 51 with the name ' _SYSSMU51$ ' too small error when running the purge process.

    I want to know if there are expired blocks available and fly count for blocks remaining is 0, so why we get error ORA-01555.

    According to below the result of the query:


    EXPIREDBLKS = 138616

    UNXPSTEALCNT = 0

    set line 2000
    SELECT *
    FROM dba_hist_UNDOSTAT
    where ssolderrcnt <> 0
    
    
    
    
    

    BEGIN_TIME            END_TIME              DBID INSTANCE_NUMBER SNAP_ID UNDOTSN UNDOBLKS TXNCOUNT MAXQUERYLEN MAXQUERYSQLID MAXCONCURRENCY UNXPSTEALCNT UNXPBLKRELCNT UNXPBLKREUCNT EXPSTEALCNT EXPBLKRELCNT EXPBLKREUCNT SSOLDERRCNT NOSPACEERRCNT ACTIVEBLKS UNEXPIREDBLKS EXPIREDBLKS TUNED_UNDORETENTION
    --------------------- --------------------- ---- --------------- ------- ------- -------- -------- ----------- ------------- -------------- ------------ ------------- ------------- ----------- ------------ ------------ ----------- ------------- ---------- ------------- ----------- -------------------
    6/21/2014 10:15:21 AM 6/21/2014 10:25:21 AM 8337               2   50429       8    17969    27294       15780 77kuu26yggxym             19            0             0             0           0            0            0           1             0       9904       1549952      138616               13262
    
    
    
    

    > so why we get error ORA-01555.

    The session that signals the ORA-01555 is the victim; not the culprit.

    This session is probably made a LONG run SELECT against other tables.

    Done some session also DML against this same table and launches 'frequent' COMMIT (usually inside the LOOP).

    Eliminate common VALIDATION & the ORA-01555 error no longer is.

  • When there are multiple users e-mail of files that are on the left of the screen can be hidden by other users?

    There are several people who might want to use Thunderbird on a work computer, but I don't like how all the e-mail files are open to the public view. It looks like anyone can see the emails without having to log on the account of others.

    It is regrettable indeed, and I don't think it's a good idea.
    You can opt for individual profiles, but this doesn't quite work for multiple users.

  • My thing to the notifaction red circle imessage is not popping up even when there are unread texts.

    Even will not appear my red imessages bubble. Even when I just get a message as well. There are some unread messages again and I did not open my app again and again, it does not show the number of notifications to the application. Help, please.

    Hi risa212,

    Welcome to the communities of Apple Support! I'm sorry to hear that you are having these problems with your iPhone. If you do not see the Red badge of notification of unread messages in the Messages, you can check the Notification settings to ensure that the notification of the badge has not been disabled:

    Change Notifications settings

    Some applications such as email or social media applications send frequent notifications that could affect the battery life. If you have the show on lock enabled for notifications screen, it could also affect the autonomy.

    To disable or change notifications, go to settings > Notifications and select the app. You can also sort your most recent alerts, order them manually, or group them based on the application.

    If you do not see the notifications for a specific application

    To get notifications, you must be connected to a Wi - Fi or cellular network. If you do not get notifications for a specific application, try the following steps:

    1. Make sure that the application supports notifications. Go to settings > Notifications, select the application and make sure that Notifications are turned on.
    2. Make sure that you are connected to your Apple ID on your iOS device. Go to settings > iTunes & App Stores and enter your Apple ID and password.
    3. Make sure you do not disturb is turned off. Go to settings > do not disturb and tap manual if it is enabled.
    4. If you have recently installed an app or restored from a backup, open the app to start to get notifications.

    Use the Notifications on your iPhone, iPad and iPod touch - Apple Support

    Concerning

  • No connection is available when there are actually available connections... !

    my laptop was working normally and my connection to any wireless network has been very well until the wireless adapter started turning to the so I just turned it again... An hour before, he couldn't just connect to any wireless network and whenever I try to connect to the internet without wire - ly, I can't as he said, no connection is available, while there are indeed available connections.

    When I address the problem, he says: "windows is unable to solve problems of wireless connectivity.

    The wireless network adapter is NOT cut! and I just put a maximum performance in both "trendy" and "battery." but in vain...

    I don't know what the problem is and I don't know how to fix it :/

    I can connect to the internet through a "cable". and the wireless LED is lit in the router as my phone and all the other home PC can connect to him... except for my laptop...

    Thanks in advance...

    My operating system for laptop Dell inspiron N5110

    Windows 7...

    Please, let me know if you know any, so I can solve this problem...

    Thanks again,

    Sarah

    I use NORTON Antivirus.

    I headed to the "Device Manager" and:

    I uninstalled the network card named "Dell Wireless 1702 802. 11b / g/n

    then I pressed 'Search the hardware changes' and installed it again, but nothing happened.

    I restarted the laptop and then I COULD CONNECT to the INTERNET!

    I'm always a perfect ignoring what and why was that...

    I'm sorry for the trouble here...

    Thank you.

Maybe you are looking for