Count SQL not working as needed

Hi,
I'm having a few problems with some SQL ...
I have and want and getting the following...
Have table...
Male | Female | OAP | Homeowner | Date
Y     -     Y     -     12-Aug-07
-     Y     -     -     11-Sep-06
Y     -     -     -     21-Jun-04
Y - Y - 18-Jul-08
Want it to return...
Male | Female | OAP | Homeowner | Count Date
Y     -     -     -     2
-     Y     -     -     1
-     -     Y     -     1
-     -     -     Y     0
Actually returning..
Male | Female | OAP | Homeowner | Count Date
Y     -     Y     -     2
-     Y     -     -     1
Y     -     -     -     1
Code using ...
select male, female, OAP, owner, Count(d_date) "Count date" from si_test
Group by male, female, OAP, owner;
Any ideas?
Cheers,
Si

SQL> create table si_test (male,female,oap,owner,d_date)
  2  as
  3  select 'Y', null, 'Y', null, date '2007-08-12' from dual union all
  4  select null, 'Y', null, null, date '2006-09-11' from dual union all
  5  select 'Y', null, null, null, date '2004-06-21' from dual union all
  6  select 'Y', null, 'Y', 'N', date '2008-07-18' from dual
  7  /
Table created.
SQL> update si_test set owner = null where owner = 'N'
  2  /
1 row updated.
SQL> select male
  2       , female
  3       , oap
  4       , owner
  5       , count(d_date) "Count date"
  6    from si_test
  7   group by male
  8       , female
  9       , oap
10       , owner
11  /
Male Female OAP Homeowner                             Count date
Y           Y                                                  2
     Y                                                         1
Y                                                              1
3 rows selected.
SQL> column male format a4 heading "Male"
SQL> column female format a6 heading "Female"
SQL> column oap format a3
SQL> column owner format a9 heading "Homeowner"
SQL> column countdate format 999999 heading "Count Date"
SQL> select t.male
  2       , t.female
  3       , t.oap
  4       , t.owner
  5       , case
  6         when t.male = 'Y' then si_test.countmale
  7         when t.female = 'Y' then si_test.countfemale
  8         when t.oap = 'Y' then si_test.countoap
  9         when t.owner = 'Y' then si_test.countowner
10         end countdate
11    from ( select 'Y' male, null female, null oap, null owner from dual union all
12           select null, 'Y', null, null from dual union all
13           select null, null, 'Y', null from dual union all
14           select null, null, null, 'Y' from dual
15         ) t
16       , ( select count(male) countmale
17                , count(female) countfemale
18                , count(oap) countoap
19                , count(owner) countowner
20             from si_test
21         ) si_test
22  /
Male Female OAP Homeowner Count Date
Y                                  3
     Y                             1
            Y                      2
                Y                  0
4 rows selected.Regards,
Rob.

Similar Messages

  • I restored my iphone and updated it but the progress didn't complete and now my iphone is not working. i need help asap.

    my phone was not working only the restore button was available so i restored it and they told me i have to update my iphone 5s as well. i waited till the end the update software was downloaded successfully but then the iphone restarted by itself and now its not working. the iphone screen is shown the picture when you first time open the phone to connect it to an itunes. i connected it by it not working, i restart everything still not working:( i need help asap please. thankyou

    it seems like apple's activation servers have gone down under the weight of the overwhelming amount of activation requests. you will be able to activate your phone once the servers are able to catch up with the activation requests.

  • I purchased my iphone 4s from US, my lock button is not working, I need to get it repaired in India. Please suggest

    I purchased my iphone 4s from US, my lock button is not working, I need to get it repaired in India. Please suggest

    There is nothing you can do except take it back to the US. The warranty is not international and no authorized service center will touch your US phone in India.

  • TS1702 Hello, I,m having problems with Polish spell check. It says in iPnstruction that this App (pages) should show my writing mistakes. Check spell button is on but but check spell is not working. Need help Please.

    Hello, I,m having problems with Polish spell check. It says in iPnstruction that this App (pages) should show my writing mistakes. Check spell button is on but but check spell is not working. Need help Please.

    Hello, I,m having problems with Polish spell check. It says in iPnstruction that this App (pages) should show my writing mistakes. Check spell button is on but but check spell is not working. Need help Please.

  • MDX -Children count function Not working in Case statement

    Hi,
    I am trying to create set when you slice with the Hierarchy member is leaf level , I want a output only that Leaf level .
    and When I slice with  the parent level , it has to give all the members below that parent level.
    But the problem here is when I select child member or leaf member , The first condition in the Case is not working
    WITH SET
    TESTSET AS
    CASE
    WHEN
     [Dimension].[Hierarchy].currentmember.children.count<0
    THEN
     [Dimension].[Hierarchy].currentmember
    ELSE
     DESCENDANTS([Dimension].[Hierarchy].Currentmember,,AFTER)
    END
    SELECT
    WBSSET ON 1,
    {} on 0
    FROM
     (SELECT {[Dimension].[Hierarchy].&[10]} ON COLUMNS FROM [CubeName])
    Thanks,
    Santosh

    Hi Santosh,
    I don't think Children count function not working in case statement, I have tested it on my local environment, here s the sample query for you reference.
    with member
    testset as
    case
    when
    [Geography].[Geography].currentmember.children.count<10
    then "X"
    else "OK"
    end
    select testset on 0,
    {[Geography].[Geography].[Country].members} on 1
    from
    [Adventure Works]
    In your scenario, the issue might be caused by the query isself, you can try to use IsLeaf Funcion to achieve your requirement. Please refer to the links below.
    http://msdn.microsoft.com/en-us/library/ms144932.aspx
    http://www.databasejournal.com/features/mssql/article.php/3633696/MDX-Operators-The-IsLeaf-Operator--Conditional-Logic-within--Calculations.htm
    http://www.mdxpert.com/Functions/MDXFunction.aspx?f=22
    Regards,
    Charlie Liao
    TechNet Community Support

  • The reproduction counter does not work correctly

    the reproduction counter does not work correctly

    Yes it is a bug, and no one is being lazy.
    People volunteer their time to bring you a mail client and as soon as there is anything like a problem, someone is being lazy. Seriously, that is not acceptable. Before commenting on the contributions of others, please advise what your contributions have been.
    Bug [https://bugzilla.mozilla.org/show_bug.cgi?id=1107844 1107844 ]refers

  • Buy From Japan iphone 5 now am in ksa. but ksa carrier not working i need to work all sim card my iphone

    Am buy from Japan iphone 5 now am in ksa. but ksa carrier not working i need to work all country sim my iphone

    There are no officially unlocked iPhones sold in Japan, and none of the Japanese carriers offer official unlocking for the iPhone. Thus, there is no way to get any Japanese iPhone officially unlocked to work anywhere other than Japan
    Sell it, as you will not be able to get it officially unlocked.

  • My MBP display is not working.  Need to move data to new MBP Retina.

    Hello.
    My 3 yr old MBP display failed (display just showing vertical and horizontal lines).
    I bought a new MBP Retina today.
    Genius Bar told me to simply attach FireWire, then press "T" on old MBP to boot in Target Mode.
    Then, look for old MBP HD icon on new MBP Retina desktop.
    I cannot find old MBP icon on desktop.
    I cannot transfer data from old MBP to new MBP Retina.
    Any help would be appreciated?
    Ken

    Genius bar told you right - you need to start your old MBP up into target mode (booting while hold down the T key) but you need to have the right FireWire cable hooked up to the machines before you boot either. What year is your old model? Does it hve FW400 or FW800?
    Here are the instructions from Apple - http://support.apple.com/kb/HT1661. Take a look at it and see if it helps. Also make sure that you have the Finder set so that external and remote disks will show up on your Desktop. When the disk mounts you can either just copy over files or, if you want to transfer accounts and associated directories, use Migration Assistant in your Utilities folder to copy over the info.
    Good luck - call back if it's not working.
    Clinton

  • Working in Sql, not working in Stored procedure

    Dear friends,
    I am puzzled about this strange working of Oracle , although I know that there is some problem with my code. I paste my code here. The delete statement is working properly in SQL Plus 8.0, but it is not working when I call this stored procedure from the Form.
    FUNCTION delete_record_treaty (
    p_treaty_id T_RIN_TREATY_MST.TRTY_ID_GV%TYPE, p_value VARCHAR2,p_block VARCHAR2 )
    RETURN BOOLEAN IS
    v_treaty_type varchar2(5);
    BEGIN
    v_treaty_type := substr(p_treaty_id,1,3);
    if p_block !='T_RIN_GRP_DTL' and p_block != 'T_RIN_XOLSLAB_DTL' and p_block!='T_RIN_PMTSCHD_DTL' then
    delete from T_RIN_TREATY_MST where TRTY_ID_GV=p_treaty_id ;
    commit;
    end if;
    if v_treaty_type = 'QTA' then
    delete from T_RIN_GRP_DTL where TRTY_ID_MV=p_treaty_id and T_RIN_GRP_DTL.ROWID = p_value;
    commit;
    elsif v_treaty_type = 'XOL' then
    delete from T_RIN_XOLSLAB_DTL where TRTY_ID_MV=p_treaty_id ;
    delete from T_RIN_PMTSCHD_DTL where TRTY_ID_MV=p_treaty_id ;
    elsif v_treaty_type = 'FAC' then
    delete from T_RIN_PMTSCHD_DTL where TRTY_ID_MV=p_treaty_id ;
    end if;
    RETURN(TRUE);
    END delete_record_treaty;
    Thanks in advance.
    All the paramaters that I pass, are correctly being passed to this stored procedure.
    null

    I solved it.One parameter I was passing it wrongly.
    Gee :D
    Subramanian V.

  • Stor.e TV not working (firmware needed if posible)

    I recently bought a Store TV 1.5 tb and as it was not working for Ubuntu I formated it and made it fat 32. Now it's not working on my tv, when I plug it, in the background of the original menu appears but not the folders or any other option. If I press config. on the remote I can change video or sound configurations but that's it.
    If someone knows any way to repair it please help me.
    I would also need if possible the original firmware or all the original files inside the device, including hidden folders.
    Thank You

    I don't have this HDD but the situation is complicated. If there is some firmware update it must be available on Toshiba download page.
    I don't know what to say but maybe you should contact Toshiba service.
    I mean they have access to Toshiba database and I think they can help you with all this.

  • WHY DOES THIS SQL NOT WORK

    I have 4 statements.
    echo off
    plus80 / @z:\nesp1483_batch
    plus80 / @z:\nesp1484a_batch
    exit
    The first statement plus80 / @z:\nesp1484_batch inserts records into a table and creates a report and deletes the table.
    However the second statement plus80 / @z:\nesp1484a_batch is not working properly. I want it to insert records into a table, create a report and then delete the table but it is not working properly. It is hanging up on this statement.
    I need to say plus80 to get the program to execute properly.
    I have also tried sqlplus /@z:\nesp1484a_batch but this does not work either.
    What do I need to do to make the third statement to execute properly?

    I know that it is not working
    because the response time is slow and I have over 15 minutes
    and nothing is happening. How do you know it is not working as opposed to just working slow?
    Do you have any logging routines in your code? If you have, switch on them on and see what's happening. If not, now is a good time to think about including them...
    Cheers, APC

  • JDBC (SQL) not working in thread

    I was surprised by a strange (bug?)
    I had two programs that were implementing the Java Serial Port API, each interfaced to a specific instrument. I was asked to combine the two programs into one, run it on one workstation, and run it as a service. This is on an W2K machine and they want it to work even if no one is logged in.
    Well, I started each class as a serial port listener and a runnable, thinking it might be best for each listener to have its own thread. That runs just fine. But, one of the instruments sends a lot of data, so once I had a buffer full of stuff to parse and upload (to Oracle), is started another processing thread to handle the data, and let the parent thread get back to listening to the serial port.
    Well, I parsed the data just fine, but after I created the connection, created a statement, and then tried to execute a line of SQL, it just stopped, no exceptions, but no results. I keep a log of what is going on, and it looks like the thread just dies.
    So, for experimenation, I changed the parent threads back to plain classes and created the instances of them, still leaving the processing piece as a thread. (The only draw back to this is that I cannot transmit from both instruments at the same time.) Well, the SQL worked fine, so I am wondering if there is a problem with the JDBC and threads, or inner threads?
    Anyone have any suggestions?
    Thanks,

    As I understand it, your code does not work only when you run it as a service. Although I may well not understand it (for example I don't know what you think an "inner" thread is, and I don't understand your distinction between "class" and "thread", since everything runs in some thread or other in Java).
    Is this correct? Have you managed to get the original (single instrument) code running as a service? My guess is that there's nothing wrong with Java, but there is some issue with running it as a service.

  • Manually set IP addresses not working as needed

    We have setup our DCHP server in that we manually not dynamically give IP addresses to workstations according to there mac addresses. But most of the time the the workstations go and get the IP addresses dynamically, and in this case most of the time we get IP conflict. Does it mean the giving IP addresses manually does not work properly in the DHCP configuration. For reasons, we need to use Manually assigned IP addresses not dynamically. And how can I trace why the manually configured workstation go and get IP addresses dynamically ?

    It should work properly. Please post your configuration.

  • Please help!! Laptop is not working and needed for homework!!!

    I have a Toshiba laptop. The model is Satellite A215-S5837. The problem I have is this. Starting this morning when I turned on my laptop it was black for 10 minutes and then it starts loaing files. After it is finished loaing it goes to the regular Windows Vistas is loading screen. Then it goes black again and after 10 more minutes the mouse cursor shows up an nothing else. It nevr gets to the welcome screen where I can log on. It just stays black with a mouse cursor that responds when I move it. Please help quickly because I have homework ue soon for my summer class and I need to finish it tommorrow else I fail.
    P.S. Please don't tell me to restore my computer because I don't have my restore disk with me because I am currently studying abroad.

    Re: Please help, printer is not working "ink system failure" 
     12-13-2009 02:52 AM
    Please help, printer is not working "ink system failure" 
     13
    -12-2009 02:29 AM
    Hi,
    Any help appreciated.  My printer is Photosmart C7288 All-in-One Printer.
    As of 2 days ago my printer has not been working. It comes up with several error messages after I switch it on. The first one is "Ink system failure: Ink system has failed. Unable to copy, recieve faxes or print. Refer to printer documentation. Error: 0xc18a0105. Turn power off then on again." 
    However when I turn power off then on again via the 'power' button, ".ink system failure Then the same original error message comes up (0xc18a0105). This is the most frequent error message and won't go away. Then I also keep getting a message saying "Photo Tray Problem: Lift output tray up, verify the photo tray is pushed in until it stops, lower output tray". Despite the fact that I have not used the photo tray in several months and it is in the correct position. 
    So far I have tried switching the printer on and off several times using the power button. I also switched the printer off at the plug last night (after it had been properly shut down) and switched it back on this morning. I have looked through the printer documentation but could not find any troubleshooting advice for this kind of problem. I have updated the HP driver using software update on my mac, and the problem is still there. 
    I'm getting desperate now, I rely on my printer/scanner/photocopier a lot!
    Thanks
    karaman bera

  • My up button for volume does not work and need to turn incoming call volume up. is there an app to do this

    my up volume button does not work and i need to turn the incall volume up. is there an app that does this?

    Hey skeith75,
    Thanks for the question. Based on the information you have provided, your iPhone may need to be serviced to fix that button. However, if in the meantime you would like a workaround for turning the volume up on a phone call, you can use Assistive Touch:
    iOS: Using AssistiveTouch
    http://support.apple.com/kb/HT5587
    If you do wish to service your iPhone, the following link should help you get started with the process. Included, you will find information on topics such as warranty, service pricing, and express replacement service.
    Apple - Support - Service Answer Center
    http://www.apple.com/support/iphone/service/faq/
    Thanks,
    Matt M.

Maybe you are looking for

  • Is my iPhone's warranty still active ? I had a little accident.

    Hello guys. I have a problem with Siri not listening (after some searching I found out that apple will replace my iphone for this problem), but recently I dropped my phone and I cracked the glass in the upper right corner (about a 0.15in crack - almo

  • Billing docs problem

    Dear all, SD billing I create it 20.07.2010. FI document cleared it by 30.07.2010. But some body cancel this billing document by 09.09.2010 how it is possible to cancel it ....once it was cleared? Please advice me. Bishnu 21/09

  • Why does 'run as Administrator' fix my Silver Efex problem?

    I have had a problem with the Nik Software Silver Efex Pro (SEP) plugin running extremely slowly, but only at certain times. It's been pretty good for the past few months, but it suddenly took a nose-dive a few days ago. It takes ages to load the pre

  • TS4002 iCloud Mail Issues

    Why doesn't the text in my incoming email show? Why don't new emails show? There is a number on my "mail" icon showing new mail but, there is no new mail in my inbox. My iPhone shows the mail but it is not showing up on my MacBook.

  • How to make this script work

    Help me to make this script work, please! function(){ app.findGrepPreferences.firstLineIndent  = "8 mm"; app.findGrepPreferences.leftIndent  = "8 mm"; app.changeGrepPreferences.firstLineIndent  = "8 mm"; app.changeGrepPreferences.leftIndent  = "16 mm