Left Outer Join does not work why?

Hello

I have a question I want to return all the id group grp_id table and count and give me a count of all "active" members in the Member table. There are a few members who are not active in the table of members who belong to groups in the grp_id table. I still want a record returned for these grpid, but since there is no active members for these groups, I would like a zero as the mbr_count. An active mbr is the one whose eff_dt is less than the date of the day and whose exp_dt is greater than today's date.

I have listed the query below, which returns active records mbr, but unfortunately does not return a grpid (as in my example of data) is not an active member (grpid: has ""). I have also provided the DDL for both tables as well as some examples of data that gives me the (Incorrect) results, that I posted. I have also posted what I need (the 'Correct' results).

Thanks for any help... (I use PL/SQL)

THE QUERY I USE:
=============
SELECT
G00.grpid,
Count (M00.grpid) mbr_count
Of
g00 grp_id
LEFT OUTER JOIN
m00 MBR on
G00.grpid = m00.grpid
WHERE
M00.eff_dt < sysdate
AND
M00.exp_dt > sysdate
GROUP BY
G00.grpid

It gives me results like:

INCORRECT RESULTS:
===============
GRPID MBR_COUNT
A 2
B 2
C 1

I want to see is:

CORRECT RESULTS
===============
GRPID MBR_COUNT
A 2
B 2
C 1
D 0


Here's the DOF and the sample data:

create table grp_id (grpid varchar (1))

insert into grp_id values ('A')
insert into grp_id values ('B')
insert into grp_id values ('C')
insert into grp_id values (')

Commit

create table mbr (mbr_name varchar (10), varchar (1) grpid, eff_dt date, exp_dt date)

insert into values of mbr ('BRAND', 'A', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (July 1, 2011 ',' DD-MM-YYYY '))
insert into values of mbr ('BRAND', 'A', to_date (July 1, 2011 ',' DD-MM-YYYY '), to_date (1 January 2012 ',' DD-MM-YYYY '))

insert into values of mbr ('MARTY', 'A', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (July 1, 2011 ',' DD-MM-YYYY '))
insert into values of mbr ('MARTY', 'A', to_date (July 1, 2011 ',' DD-MM-YYYY '), to_date (1 January 2012 ',' DD-MM-YYYY '))

insert into values of mbr ('FRANK', 'B', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (July 1, 2011 ',' DD-MM-YYYY '))
insert into values of mbr ('FRANK', 'B', to_date (July 1, 2011 ',' DD-MM-YYYY '), to_date (1 January 2012 ',' DD-MM-YYYY '))

insert into values of mbr ('MARY', 'B', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (July 1, 2011 ',' DD-MM-YYYY '))
insert into values of mbr ('MARY', 'B', to_date (July 1, 2011 ',' DD-MM-YYYY '), to_date (1 January 2012 ',' DD-MM-YYYY '))

insert into values of mbr ('JOHN', 'C', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (July 1, 2011 ',' DD-MM-YYYY '))
insert into values of mbr ('JOHN', 'C', to_date (July 1, 2011 ',' DD-MM-YYYY '), to_date (1 January 2012 ',' DD-MM-YYYY '))

insert into values of mbr ("NOAM" 'd', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (July 1, 2011 ',' DD-MM-YYYY ') ")

Thanks for the script, shame on the missing semicolon :)

Your date restrictions are implemented as "filter predicates" rather than "join predicates.
that is the difference between a place ANDS extra o in the JOIN clause.

SQL> SELECT
  2  g00.grpid,
  3  count(m00.grpid) mbr_count
  4  FROM
  5  grp_id g00
  6  LEFT OUTER JOIN
  7  mbr m00 on
  8  g00.grpid = m00.grpid
  9  WHERE
 10  m00.eff_dt < sysdate
 11  AND
 12  m00.exp_dt > sysdate
 13  GROUP BY
 14  g00.grpid
 15  /

G  MBR_COUNT
- ----------
A          4
B          4
C          2

SQL> SELECT
  2  g00.grpid,
  3  count(m00.grpid) mbr_count
  4  FROM
  5  grp_id g00
  6  LEFT OUTER JOIN
  7  mbr m00 on
  8  g00.grpid = m00.grpid
  9  AND
 10  m00.eff_dt < sysdate
 11  AND
 12  m00.exp_dt > sysdate
 13  GROUP BY
 14  g00.grpid;

G  MBR_COUNT
- ----------
D          0
A          4
B          4
C          2

SQL> 

Tags: Database

Similar Questions

  • Filters Photoshop CS6 Gallery is visible (not grayed out) but does not work.

    Filters Photoshop CS6 is visible (not grayed out) but does not work.

    I opened in 8-bit RGB jpeg.

    I can use the options of fluidity and blur, but nothing in the Gallery of filters (for example cutting).

    I am running on a MBPro CS6, recently restarted, 16 G of RAM, OSX 10.11.1

    I get no effect for smart objects or rasterized jpegs.

    You will notice the cut filter is selected, but has no effect on the picture.  There is no error message.

    It looks like I could use the filters a month ago.

    Thank you.

    Jeff

    Screen Shot 2015-12-14 at 10.42.37 PM.png

    The preview is enabled.

    Click just to the left of the opening.

  • The Stream.play () method does not work why?

    I want to create an application to switch streams and republish them under continuous flow unique to the remote server.

    In the first step, I tested "Livestream code" of the "Multipoint publishing example" p. 184 of "FLASHMEDIA SERVER 4.5 Developer's Guide ADOBE®" If ns.publish method is used. He managed.

    I try stream.play method now.

    I wrote main.asc code as in the Stream.play example (p. 162) of the 'the ACTIONSCRIPT Language Reference® to ADOBE® FLASH® MEDIASERVER 4.5 server-side", but I have a certain problem despite this.

    I try to spread on my local server (Uri - "localhost/studia") by two customers - OUT and my request for "Livestream" accordingly (with stream name "livestream2") and retraslate it to a remote server by using my "studia" on a local application.

    The connection between two servers (with application "on-line") appears in the Remote Server Admin Consol, but the flow of my local server do not come to her.

    Here's my main.asc script:

    application.myRemoteConn = new NetConnection();

    application.myRemoteConn.onStatus = {function (info)}

    trace ("Connect" + info.code + "\n");

    Respond to all customers

    for (var i = 0; i < application.clients.length; i ++) {}

    application.clients [i]. Call ("onServerStatus", null, info.code, info.description);

    }

    };

    Connect use NetConnection object remote server (the remote server works with other application wery well)

    application.myRemoteConn.connect ("rtmp://RemoteServer/live");

    Estimate of the server data flow

    application.myStream = Stream.get ("livestream");

    application.myStream = Stream.get ("livestream");

    If {(application.myStream)

    application.myStream.play ("livestream2", 0, -1, true, application.myRemoteConn);

    }

    The Stream.play () method does not work why?

    What I've done wrong?

    In this case, I recommend a mixture of solution...

    Something like that will be interesting to check:

    var tempSwitchingStream = Stream.get ("myswitchingstream"); create a stream live temp on the server local app...

    tempSwitchingStream.play (livestream1, 0, -1);      Subscribe to tempSwitching to livestream1... That is to say get the content of livestream1 in there... I can also switch to different streams inside... tempSwitchingStream will get the contents of the stream of //switched

    If (tempSwitchingStream) / / if there is

    {

    NS. Attach (tempSwitchingStream);  Subscribe to my net workflow to receive data from tempSwitchingStream

    NS. Publish (livestream, "live");  now flows net is get data from tempSwitchingStream, so publishing those data with the name "livestream" on the connection to the network... NET already know its NetConnection... See above

    }

    Did you get the point? I created a temporary stream that can pass the stream in its method of game and then I push this temporary stream to a remote server...

    However, it is tricky... Majorly, in most cases similar to yours, people write applications on the application of remote server to get the stream and he spend the pull in play method as described in the first method discussed...

  • TV out button does not work on my Satellite Pro M30

    Hello

    I installed Windows XP SP2 and all drivers for M30 but the "TV out" button does not work although I have also installed the tool "Controls Button from Toshiba" (continues to ask to be assigned to a program), it worked before installing the new.

    I also noticed that the "Fn + F5" also does not work too (eg. do not send the signal to the TV).

    Can anyone help?, thanks in advance.

    Hi Karim

    Write about you? :)

    In any case, try to install TOSHIBA common Modules again. Maybe it helps!

  • Satellite P750-136 - left mouse button does not work

    I don't understand what the problem is. My left mouse button does not work. If I put a little pressure on the Panel located under the button space then the left button of the mouse works.

    What should I do? It feels like a hardware problem, since I bought the laptop in November my laptop is still covered by the warranty.

    What you can do is to check the touchpad settings and make sure that everything is OK.
    I'm don't know if you noticed this since day 1, but if you think it is hardware problem I recommend you contact the nearest Toshiba service provider as soon as possible. Warranty will cover all repair costs.

  • Re: Left mouse button does not work on Satellite L

    Hello

    I bought this computer notebook June 2010 and I never had no problem recently while watching movies has suddenly stop and happens quite often... and recently, I noticed that my left mouse button does not work correctly

    all useful suggestions please

    Thanks in advance
    Pramod

    Hi pramod_1,

    Have you tested an external mouse if the problem is maybe a few related software?

  • Microsoft Security Essentials - the planned-out scan does not work.

    In addition to the question about the scheduled scan output after upgrade to Windows 7 to McAfee.Microsoft Security Essentials series instead of McAfee. The scan-out plan does not work.

    Support McAfee tried to straighten my computer of conversation I understood the problem of the update disc. I want to ask a question to the update command:? many problems were very pushed us all after your update. How now to get out of this dung under the name Toshiba upgrades?

    Hey Buddy,

    To be honest I don t know what you re talking about exactly. What has to do with Microsoft Security Essentials McAfee?

    As far as I know it s recommended using a security program only. You must use a Microsoft or McAfee, but not both!

  • Free trial of Adobe Pro DC installation does not work why?

    Free trial of Adobe Pro DC installation does not work why?  The installation proceeds very slowly and simply makes anywhere between 11% and 40% before I get either a general "Error" message or one that says WebGet failed.

    I use Mac Yosemite and download of Firefox.

    You have downloaded the installer at the bottom of the link?

    Download Acrobat products | Standard, Pro | DC, XI, X

  • Read out loud does not work on protected PDF

    Read out loud does not work on protected PDF

    The document is protected by word ("password protection"). There are two kinds of passwords with a PDF file.

    1. a password to open. This should be used to open the file. The file could have the safety limits.

    2. a password control. This is necessary to change the limits of security.

    If this file has no password open, but it has a password of control. Without it, "accessibility ay cibteby enabled: no authorized (e)" previous lire.

  • my master password does not work, WHY?

    I used my master password for quite awhile. Today when I put it in it does not work. HOW CAN THIS HAPPEN? I saw the the way to remove it, but then I lose about 28 login and password for all my financial sites. Why the P/W does not work? AND why would you if it can FAIL. Y at - it another way around this in addition to a total deletion of all my other passwords. I tried to restart my computer a couple of times to see if it would fix itself, but nothing helped.

    Have you tried to close and restart Firefox or restart the computer to see if it have an impact?

    What security (firewall, antivirus) software do you have?

    If the MP password does not work and is not accepted if you get a prompt to connect to the software security device, then it is likely that the signons3.txt file got damaged or replaced by an older version.

    You have a backup of files in the Firefox profile folder?

  • "set the restart target action" does not work, why?

    There is an element of "set the restart target action" in the SDF file. I put it to "run a system definition.

    But it does not work. I don't know why. It seems that when the project is canceled, the SystemDefinitionData.nivscfg file is deleted.

    Cancel the deployment of will stop the configuration and mark idle.

    If you restart the RT target by HW button or through the channel "System of command channels", while the configuration is active, it will start the Setup again after the reboot.

    Jiri K.

  • Aero does not work why?

    This number is displayed in the name of another user.

    Hello

    The Aero feature does not work in Windows 7. I tried the following links for assistance:

    http://support.Microsoft.com/kb/976170

    http://support.Microsoft.com/mats/aero_effects_not_working/en-us

    It stopped working after the use of a screen recording software. I got out of this, verified that my screen resolution is correct and video card drivers are updated, but it still does not work. Does anyone have any ideas or suggestions, that I can try?

    Thank you

    Social media - Dwayne W

    P.S. I ask the user to monitor this post and try the suggestions.

    Hello

    1. which edition of Windows 7 is on the computer?

    2. what happens when you try to choose the Aero theme?

     

     

    Method 1: Uninstall screen recording software and see if that helps.

    See the following article:

    Uninstall or change a program:

    http://Windows.Microsoft.com/en-us/Windows7/uninstall-or-change-a-program

     

    Method 2: SFC scanner.

    System File Checker (SFC) scan will replace the missing or corrupted system files on your computer.

     

    Reference:

    How to use the System File Checker tool to fix the system files missing or corrupted on Windows Vista or Windows 7

    http://support.Microsoft.com/kb/929833

     

     

    Method 3: The restore of the system; restore the computer to a date when it was working fine before.

    Reference:

    System Restore: frequently asked questions:

    http://Windows.Microsoft.com/en-us/Windows7/system-restore-frequently-asked-questions

  • Clipboard in Fx Android does not work why?

    (Hope this isn't a duplicate: when I started posting, the system asked me to confirm my e-mail address and said that my message would be displayed, but the system said now I haven't sent anything.) A little later: my mistake, a misunderstanding of the language of the system forum. I had posted, which seems to not be the same as sent. My original post was, in fact, posted, but I looked in the wrong place.)

    With Android Kitkat 4.x, I could set up an account with Keepass, get my user name or password saved to the Clipboard, then go to Fx, set up a logon account page, press and hold in the area id or password, and the popup 'Paste' seems to me; clicking on the icon would transfer the data from the Clipboard to the corresponding logon box.

    With Android 5.0 Lollipop, it does not work: instead of the paste popup, I get an arrow in the login box telling me where to type in the data. I know the Clipboard Android works: using Keepass, I can record the date in the Clipboard and then, for example, go to Gmail, hold on, 'Paste', click on that and see the Clipboard data transferred to Gmail. The Fx problem exists since I received my phone Moto X last March thanks to every Android Fx update, the most recent of which this release.

    When I long press on the field, I get a bar upstairs that has an icon of the dough. I have attached a screenshot (reduced size) of what I see. (It was one thing to chance, that I copied, because I don't have Keepass.)

    You don't get something like this?

    Oops, perhaps it is 5.1 and not 5.0

  • I downloaded the (US) dictionary and spellchecker - it's showing in my modules - but it does NOT work - WHY?

    I added the English spelling corrector of the United States (US) 5.0.1 - it is in my modules, spellchecker is checked in tools/options - and I restarted firefox after it said 'successful' - However, it still does not work.
    Is there anything else I need to do?
    Help, please!
    TY

    TY so much... it works now. I see what I was doing wrong. I would right click, but not on the misspelled word and the area to correct the spelling & "add to Dictionary" did not come upward. After reading your response and clicking on the link, I decided to try by clicking right on misspelled word... YEAAAAAAAAAAA!
    Yet once, so I appreciate your prompt response & look forward to transversing again in the future.
    Have a nice day (night)
    Jonie

  • LM324 oscillator does not work, why?

    It is a typical noob question, I'm afraid...

    In the datasheet of the LM324 I found (page 13), a circuit for an oscillator design. http://www.TI.com/lit/DS/symlink/LM324-n.PDF

    I tried to reproduce this oscillator in MultiSim, but it does not work as it is supposed to; even measure voltages higher than the voltage of the source?

    Can someone tell me what I am doing wrong?

    TYhnak you, it works fine now.

    The model manuf. button shows only ITT/LM324A_2

    Perhaps it is also because of my old version 10?

    Thnaks you very very well!

    Martin

Maybe you are looking for