Failed to get the desired result

Hi gurus

Don't know why I get the following output:

Query

SOME jobs,

COUNT (*),

COUNT (CASE job WHEN 'CLERK' THEN 1 ELSE 0 END) cnt

WCP

Working GROUP;

The query result

WORK, COUNT (*), CNT

3 3 CLERKS

4 4 SELLER

THE PRESIDENT 1 1

MANAGER 3 3

1 1 ANALYST

According to my understanding, the result should be as below:

Result must be

WORK, COUNT (*), CNT

3 3 CLERKS

SELLER 4 0

THE PRESIDENT 1 0

MANAGER 3 0

ANALYST 1 0

Thanks in advance.

Concerning

Shu

Hello

Shuumail wrote:

Hi gurus

Don't know why I get the following output:

Query

SOME jobs,

COUNT (*),

COUNT (CASE job WHEN 'CLERK' THEN 1 ELSE 0 END) cnt

WCP

Working GROUP;

The query result

WORK, COUNT (*), CNT

3 3 CLERKS

4 4 SELLER

THE PRESIDENT 1 1

MANAGER 3 3

1 1 ANALYST

According to my understanding, the result should be as below:

Result must be

WORK, COUNT (*), CNT

3 3 CLERKS

SELLER 4 0

THE PRESIDENT 1 0

MANAGER 3 0

ANALYST 1 0

Thanks in advance.

Concerning

Shu

COUNT (*) tells you how many lines there are.

COUNT (exp) tells you how many lines have a value not NULL in exp

Your CASE expression never returns null; It always returns a value of 0 or 1, but never NULL.  So, if exp is never NULL, so each line has a value not NULL and if COUNT (*) and COUNTY (exp) are always the same.

Tags: Database

Similar Questions

  • How to get the desired result when subsequent month is not available

    WITH T1
         AS (SELECT 'A' COL1,
                    'B' COL2,
                    'C' COL3,
                    '01-Jan-2015' DT,
                    10 QTY
               FROM DUAL
             UNION
             SELECT 'A' COL1,
                    'B' COL2,
                    'C' COL3,
                    '01-feb-2015' DT,
                    20 QTY
               FROM DUAL
             UNION
             SELECT 'A' COL1,
                    'B' COL2,
                    'C' COL3,
                    '01-mar-2015' DT,
                    30 QTY
               FROM DUAL
             UNION
             SELECT 'A' COL1,
                    'B' COL2,
                    'C' COL3,
                    '01-may-2015' DT,
                    40 QTY
               FROM DUAL
             UNION
             SELECT 'A1' COL1,
                    'B1' COL2,
                    'C1' COL3,
                    '01-mar-2015' DT,
                    40 QTY
               FROM DUAL
             UNION
             SELECT 'A1' COL1,
                    'B1' COL2,
                    'C1' COL3,
                    '01-may-2015' DT,
                    40 QTY
               FROM DUAL)
    SELECT *
      FROM t1
    
    

    Current output:

    COL1COL2COL3DTQTY.
    ABCJanuary 1, 201510
    ABCFebruary 1, 201520
    ABC01-mar-201530
    ABC01-may-201540
    A1B1C101-mar-201540
    A1B1C101-may-201540

    Expected results

    COL1COL2COL3DTQTY.DTREQ_VAL
    ABC01/01/20151001/01/201520
    ABC01/02/20152001/02/201530
    ABC01/03/20153001/03/20150
    ABC01/05/20154001/05/20150
    A1B1C101/03/20154001/03/20150
    A1B1C101/05/20154001/05/20150

    Logic:

    If we COL1, COL2, COL3 combination for A, B, C, we have the quantity for 1 January, 1 February, 1 March, 1 may, and we don't have quantity for April 1 and June 1. I need following QUANTITY value as another column. If I use the lead, I'll get the value from May 1st to March 1st, but I want to value 0 because it is after March either.

    What I've tried so far:

    SELECT *
      FROM (WITH T1
    AS (SELECT 'A' COL1,
    'B' COL2,
    'C' COL3,
    '01-Jan-2015' DT,
    10 QTY
    FROM DUAL
    UNION
    SELECT 'A' COL1,
    'B' COL2,
    'C' COL3,
    '01-feb-2015' DT,
    20 QTY
    FROM DUAL
    UNION
    SELECT 'A' COL1,
    'B' COL2,
    'C' COL3,
    '01-mar-2015' DT,
    30 QTY
    FROM DUAL
    UNION
    SELECT 'A' COL1,
    'B' COL2,
    'C' COL3,
    '01-may-2015' DT,
    40 QTY
    FROM DUAL)
            SELECT COL1,
     COL2,
     COL3,
    TO_DATE (T1.DT) DT,
    NVL (QTY, 0) QTY,
     MONTHS.DT ALL_DATES,
     LEAD (NVL (QTY, 0), 1, 0) OVER (ORDER BY MONTHS.DT) REQ_VAL
              FROM T1,
    (    SELECT ADD_MONTHS (TO_DATE ('01-jun-2015'), LEVEL - 6) DT
    FROM DUAL
    CONNECT BY LEVEL <= 12) MONTHS
             WHERE MONTHS.DT = T1.DT(+))
    WHERE DT ISNOTNULL;
    
    
    
    
    
    

    My query works for a set of COL1, COL2, COL3, am looking how we can achieve multiple COL1, COL2, COL3 (or) otherwise better query writing.

    Thanks for your suggestions in advance.

    Thank you

    Now, to understand your condition: your additional column must indicate the amount of the next month, or zero if it is not a record for the month. How about this?

    WITH T1

    AS (SELECT 'A' COL1,)

    'B' COL2,

    COL3 'C ',.

    To_date('01-Jan-2015','dd-mon-yyyy') DT,

    QTY 10

    OF THE DOUBLE

    UNION

    SELECT 'A' COL1,

    'B' COL2,

    COL3 'C ',.

    To_date('01-Feb-2015','dd-mon-yyyy') DT,

    QTY. 20

    OF THE DOUBLE

    UNION

    SELECT 'A' COL1,

    'B' COL2,

    COL3 'C ',.

    To_date('01-Mar-2015','dd-mon-yyyy') DT,

    QTY 30

    OF THE DOUBLE

    UNION

    SELECT 'A' COL1,

    'B' COL2,

    COL3 'C ',.

    To_date('01-May-2015','dd-mon-yyyy') DT,

    QUANTITY 40

    OF THE DOUBLE

    UNION

    SELECT 'A1' COL1,

    COL2 "B1."

    COL3 "C1"

    To_date('01-Mar-2015','dd-mon-yyyy') DT,

    QUANTITY 40

    OF THE DOUBLE

    UNION

    SELECT 'A1' COL1,

    COL2 "B1."

    COL3 "C1"

    To_date('01-May-2015','dd-mon-yyyy') DT,

    QUANTITY 40

    THE DOUBLE)

    X.Col1, x.col2, x.col3, x.dt, x.qty, NVL(y.qty,0) SELECT req_val

    THE t1 x

    LEFT OUTER JOIN t1 y

    ON y.col1 = x.col1

    AND y.col2 = x.col2

    AND y.col3 = x.col3

    AND y.dt = add_months(x.dt,1)

    ORDER BY 1,2,3,4

    My query works for a DFU, am looking how we can achieve multiple UTD

    What is a DFU?

  • How to get the desired result of the post

    Hi all.
    I use APEX 4.0.
    Now, I have two pages: A, B.
    Transfer the student_id from page A to page B.
    There is an article questioned B: student_name page select the CT where student_id =: student_id;
    At the same time, I want to get the name of the student with the title of the region, I handle it like this: student name: & Student_Name. (with the '.') ;
    If the bases of the student_name on column DB, the title work. After I have change student_name based on the query, it does not work.

    How can I solve it. Thank you.

    Hi Andy,.

    It depends on If the value is defined in this field. If you set the source of the element, it is probably too late for value must be used in the title of the region.

    In general, I find that it is better to create a calculation that is running "Before Header" to set values in the page that I need to use when the page is loaded.

    Andy

  • How to get the desired result

    I have an accmaster say table where each record has detailts on an acct as actno, curr_bal, branch, acct_type I want something as below a
    branch_no - Sum (curr_bal) where acct_type like 1% ' as sb - sum (curr_bal) where acct_type like 2%'s fd of the Group table by branch in a single line as shown below

    00001 550000 65000000
    00002 75909000 2568229867

    Please tell how to do the above operation.

    Hello

    This is called a Pivot , and here's a way to do it:

    SELECT       branch_no
    ,       SUM (CASE WHEN acct_type LIKE '1%' THEN curr_bal END)     AS total_1
    ,       SUM (CASE WHEN acct_type LIKE '2%' THEN curr_bal END)     AS total_2
    FROM       accmaster
    GROUP BY  branch_no
    ;
    

    This will work in any version of Oracle, from 8.1, but starting in Oracle 11.1, you can also use the SELECT... Function PIVOT.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.

    Furthermore, your table is called
    accmaster (where, I guess, ACC means 'account') and it contains called columns
    ACTNO ( Act means 'account') and
    acct_type ( acct means 'account')
    Do you really need 3 different ways to shorten "account"? How do you recall when you used a way and when you have used another or when you used an underscore after the abbreviation character, and when you do not have? Even if you never get confused by these things, someone trying to help you, and one that should keep your code in the future, will probably. Do not use consistent, such as namespace
    acct_master
    Acct_No and
    acct_type
    ?

  • SQL query to get the desired result

    I have the array with the following values

    Account Functional currency Billing currency Amount Header 5
    101USDUSD10 h 00
    101USDCAD12 h 00
    102JPYUSD9 h 00
    102JPYCAD3.00
    102JPYSGD2.00

    If the account has one different inv_currencypar that the functional currency and then

    I have to summarize the amount in this account by viewing the billing currency

    If the account has more than one other inv_currencypar that the functional currency and then

    I have to summarize the amount in this account showing the functional currency as the currency of invoicing

    I need output like this:

    Account

    Functional currency Billing currency Total amount Header 5101USDCAD10:00 pm102JPYJPY2:00 pm

    Can we get over output in sql without writing pl/sql program?

    Hello

    According to your specific needs, here's a way:

    SELECT account

    functional_currency

    CASE

    WHEN 1 = COUNT (DISTINCT NULLIF (invoice_currency

    functional_currency

    )

    )

    THEN MAX (NULLIF (invoice_currency

    functional_currency

    )

    )

    Of OTHER functional_currency

    END AS invoice_currency

    The SUM of (amount) AS total_amount

    header5

    FROM table_x

    GROUP BY account

    functional_currency

    header5

    ;

    If you would care to post CREATE TABLE and INSERT statements for your sample data, and then I could test this.

    Is it possible to have 2 (or more) of different functional_currencies in the same account?

  • Failed to get the result set for Get_Search_Results CRMI

    Hi all

    Face with the Null pointer exception while showing the result of the RIDC "GET_SEARCH_RESULTS" Server

    So I can't get the real result of the Content server

    Here is my code:

    ClientManager IdcClientManager = new IdcClientManager();
    Customer IdcClient = clientManager.createClient ("idc://kcsezapp01:4444"); ")
    UserContext IdcContext = new IdcContext ("weblogic", "welcome1");
    HdaBinderSerializer serializer = new HdaBinderSerializer ("UTF-8", client.getDataFactory ());

    If (!) () userContext is nothing))
    {
    DataBinder binding = client.createBinder ();
    binder.putLocal ("IdcService", "GET_SEARCH_RESULTS");
    binder.putLocal ("QueryText", "dDocAuthor < start > 'pra'");

    client.sendRequest (binder, userContext);
    serializer.serializeBinder (System.out, binding);
    System.out.println ("userContext is:" + userContext);
    System.out.println ("dataBinder is:" + linking);
    Resp ServiceResponse = client.sendRequest (userContext, binder);
    System.out.println ("the answer is:" + RESP);
    DataBinder serverBinder = resp.getResponseAsBinder ();
    serializer.serializeBinder (System.out, serverBinder);
    ResultSet DataResultSet = serverBinder.getResultSet("GET_SEARCH_RESULTS");
    for (DataObject dataObject: resultSet.getRows ())
    {
    System.out.println ("" Content ID: "+ dataObject.get ("dDocName") +"\t"+" review: ' "+ dataObject.get ("dRevLabel") +"\t"+" title of the content item: "+ dataObject.get ("dDocTitle")");
    System.out.println ("author is:" + dataObject.get ("dDocAuthor"));
    }
    }

    }

    Prashant_AP wrote:

                   ResultSet DataResultSet = serverBinder.getResultSet("GET_SEARCH_RESULTS");

    Shouldn't this read "resultSet DataResultSet = serverBinder.getResultSet("SearchResults");"?

  • com.sun.messaging.jmq.admin.apps.broker.BrokerCmd failed to get the exit code of the child.

    I use D:\MessageQueue4_5\mq\bin\imqcmd.exe to get heads of JMS queues. In most of the facilities, I can retrieve the results without problem.

    At a single facility, however, I get an error when you try to run this command. Called with no arguments, it should display a list of available commands. But that's what I get instead:

    D:\utilities\imqChk > d:\MessageQueue4_5\mq\bin\imqcmd.exe

    Boot process failed.

    Could not run

    Java

    -cp

    d:\MessageQueue4_5\mq\lib\imqadmin.jar;

    d:\MessageQueue4_5\mq\lib\fscontext.jar

    -Dimq.home=d:\MessageQueue4_5\mq

    -Dimq.etchome=d:\MessageQueue4_5\mq\... \etc\mq

    com.sun.messaging.jmq.admin.apps.broker.BrokerCmd failed to get the exit code of the child.

    Other info:

    • Java is installed (version 1.7.0_17).
    • QBrowser using, I can sign in successfully and retrieve information from queue.
    • All of the named files and jar files are where they are supposed to be within the meaning of the doce above.

    I was not able to locate the source of the problem. Any ideas would be greatly appreciated.

    Thank you.

    I had this same problem and solved by editing the file \glassfish3\mq\etc\imqenv.conf manually by setting IMQ_DEFAULT_JAVAHOME as follows:

    IMQ_DEFAULT_JAVAHOME = / Files/Java/jdk1.7.0_45 program

    Note the orientation of the slash. It's on Windows, and when I used with Windows style slash escape sequence, it does not solve this problem only when I used the mangled Unix style done.

    Hope this helps,

    -Noah

  • Failed to get the status of printer/bizhub Konica Minolta C654e

    Failed to get the status of printer/bizhub Konica Minolta C654e

    Cannot print from my Mac.

    With the limited information you supplied I would check the configuration of the print queue. If you open information system (located under Applications > utilities), you will see a column on the left and if you select printers the right pane displays the print queue information. Note If you have multiple printers, you can select in the right upper pane to view its information in the bottom right pane. Can you copy this information and paste it here.

  • printer Lexmark Pro 200. Does not print the correct colors. I restarted my computer and the printer is off but get the same result.

    Printer Lexmark Pro 200.  Does not print the correct colors. I restarted my computer and the printer is off but get the same result.

    Hello

    • What were the changes made before the problem occurred?

    You try to run this fix and check.

    http://Windows.Microsoft.com/en-us/Windows7/open-the-printer-Troubleshooter

    If above does not work, try contacting Lexmark support for assistance.

    http://www1.Lexmark.com/en_US/global-services/customer-support-services/index.shtml

  • Why "bgp bestpath missing-as-worst med" command does not produce the desired result?

    Can dear all, someone tell me why "bgp bestpath missing-as-worst med" command does not produce the desired result?
    And I use GNS3 to this practice, the IOS Version: 12.4 (3)
    TKS...

    Back to the beginning:
    192.168.23.0/24 192.168.12.0/24
    RA(F0/0)-(f0/0) RB (s2/0) - RC (s2/0)
    [AS1]                    [AS2]                    [AS3]

    Configuration:
    * RA *:
    A #do sh run (config - router). b r b
    router bgp 1
    no synchronization
    The log-neighbor BGP-changes
    1.1.1.0 netmask 255.255.255.0
    192.168.12.2 neighbor remote-2
    setmed map of nearby route 192.168.12.2 out
    No Auto-resume

    IP route 1.1.1.0 255.255.255.0 Null0

    setmed allowed 10 route map
    the metric value 20

    * RB *:
    B (config - router) #do sh run | b r b
    router bgp 2
    no synchronization
    BGP always-compare-med
    The log-neighbor BGP-changes
    BGP bestpath missing-as-worst med
    neighbor 192.168.12.1 distance-1
    neighbour 192.168.23.3 distance-3
    No Auto-resume

    * RC *:
    C (config - router) #do sh run | b r b
    router bgp 3
    no synchronization
    The log-neighbor BGP-changes
    1.1.1.0 netmask 255.255.255.0
    neighbour 192.168.23.2 distance-2
    No Auto-resume

    IP route 1.1.1.0 255.255.255.0 Null0

    But when I checked out table RB bgp, as below:

    B (config - router) #do sh ip bgp
    BGP table version is 2, local router ID is 192.168.23.2
    Status codes: deleted, cushioning d s, history of h, * valid, > best, i - internal.
    r SIDE-failure, stale S
    Source codes: i - IGP, e - EGP,? -incomplete
    Network Next Hop path metrics LocPrf weight
    * > 1.1.1.0/24 192.168.23.3 0 0 3 I
    *                          192.168.12.1            20                         0  1 i

    The prefix is assigned a MED of 0, but also the best path value when I use "bgp bestpath missing-as-worst med" in how to configure bgp... :-(

    Please take a look at the discussion on the configuration of drugs to an eBGP neighbor:

    https://supportforums.Cisco.com/thread/343397?TSTART=0

    Note that BGP MED is set to 0 even if the injected BGP route from a connected route.

    The first time I came across this problem sending MED was there in a picture of 5-6 years service provider. Routes were injected into BGP with the command 'network', has been validated by OSPF routes or static to null0. Involuntary consignment of drugs was mess with load balancing between 2 links of our inbound traffic from the same upstream service provider.

    Also note that if a route is learned via iBGP, border router removes MED before the road to advertising for an eBGP peers (i.e. the above comments apply a when a route is injected locally into the border and then router BGP sent to an eBGP peer).

    I don't know what the cause of the problem that you said in your last post. It delivers last for a long time or that it does not change after a while?

    p.s. Sorry, I edited post because I said "iBGP" instead of "eBGP" at some point.

  • Can't mount NFS share - operation failed, diagnostics report: failed to get the path console for volume

    I'm trying to mount a NFS on ESXI 6 volume, but continue to operate in the error.  Googling everything nothing helped, so I'm here. Error:

    Call "HostDatastoreSystem.CreateNasDatastore" of object "ha-datastoresystem" on ESXi '192.168.xx.xx' failed.

    Operation failed, the diagnostic report: failed to get the path of the console for the volume, the name of the sample.

    The NFS share is located on a synology nas. I checked the permissions and configuration. Everything seems correct based on the various boards and KB articles.

    Ideas?

    Thank you.

    Find the esx.conf file in/etc/vmware.

    If you could also share a copy with me...

    Try to mount the NFS VMware KB: Volume fails with the error: could not resolve the host name

    Check the link as well below.

    http://www.Bussink.ch/?p=1640

  • I use the first items 14 and tried "with instructions" make a black and white video with a special color. At first, I have to use the Darkred effect, but it has no effect. Other effects do not work. Can I get the desired effect?

    I use the first items 14 and tried "with instructions" make a black and white video with a special color. At first, I have to use the Darkred effect, but it has no effect. Other effects do not work. Can I get the desired effect?

    You mean the Edit guided for a video of Black & White with color Pop, right?

    If so, the program will be directed to the Hollywood Look effects Panel and black red effect.

    If this isn't what you are doing, please let us know where you find "instructions" there is no effect of dark red I know in the program.

  • After the merger of 7 shots in panorama, it took about 5-6 minutes to get the end result and the result had only something above 1000 pixels.

    After the merger of 7 shots in panorama he tooks nearly 5-6 minutes to get the final result and this result have only something above 1000 pixels edge long photo resolution? Why is this happening? I've been fusion 7 24Mpix of Nikon D750 RAW files. I saw a promo video where he introduced and there the panorama was above 10 000 pixel wide, so it is not a limit of lightroom, but something is not. Maybe some strange décor? Thank you.

    Well, the good news is... This isn't your files.

    I produced a pano 17310 x 6039 in less than 3 minutes. With or without adjustment.

    The only differences that we have so far is the platform. Mac/Pc

    Wrong guess you managed to repeat the question. Maybe a reinstall?

    I hope that someone else (on PC) may be able to provide alternative suggestions. Let us know if you yourself are able to find a solution.

  • Error: ORA-16757: failed to get the value of this property

    Hi all
    I have an error:
    DGMGRL > see the database dbname_stb LogXptStatus;
    Error: ORA-16757: failed to get the value of this property
    I check:
    DGMGRL > see the configuration;

    Configuration - dbname_dg

    Protection mode: MaxPerformance
    Databases:
    dbname_pr - primary database
    dbname_stb - physical of the standby database

    Fast-Start Failover: DISABLED

    The configuration status:
    SUCCESS

    drcdbname_stb.log:
    RSM0: Received the request the property Get: rid = 0 x 01010000, pid = 54
    2012-10-17 15:21:14.702 of database Resource: get the LogXptStatus property
    RSM 15:21:14.702 2012-10-17 error: trying to interview a 'LogXptStatus' primary type property on a standby database resource.
    2012 10-17 error 15:21:14.702 database resource GetProperty (16501,16757)

    I don't understand this error?
    Thank you all.

    Take a look on this

    Re: ORA-00254 | Trouble with dataguard

  • Failed to get the disk partition information when you add the new data store

    Hello

    Update my ESX to version 4 Update 1 (4.0.0, 256968). Now, I'm trying to add a new data store to a cluster in vCenter and receive the following error message when I will review the current structure of the disc "error when configuring the host: failed to get the disk partition information. When I click back, then next, there's no error message but in the formatting window, I get the error "Object reference" not set to an instance of an object.

    I see this question has been asked before, but I can't seem to find an appropriate response. Anyone? The interface using CLI instead of vCenter isn't an option (alignment VMFS, workload and so on)

    I use Dell R900 with an EMC Symmetrix VMax SAN

    The size of the LUN I want to add is 741 GB

    Concerning

    Marius Aulie

    If you have a virtual machine for Windows test, you could do the following, to ensure that the logic unit number has a clean partition table:

    -set the LUN as a GROSS physical to virtual machine device

    -Run diskpart, select the drive and run the CLEAN command

    -detach the LUN to the virtual machine

    -try to create the data on the LUN VMFS store

    The size of the block of the data store where the VM test can be a problem with the above. Due to the size of the LUN, the size of the block of the data store must be at least 4 MB. Attach the LUN to a physical test system could be an alternative.

    André

Maybe you are looking for

  • Satellite L750-1PP does not stop

    Hey guys,. I have the Toshiba Satellite L750 1PP and it won't stop.When I click on the stop button, it start to close and freezes, then after a few minutes my toshiba restarts.I have Win7 Ultimate, and I noticed that the bluetooth is not working... W

  • ProBook 6465b: 6465b locked bios

    Buy a craigslist for cheap device, because the seller stated that the bios is locked. I need to access bios... help! CNU14001DC

  • Cannot delete the file search results

    I uninstalled a program but the files in the folder that has been deleted appear always in my indexed search results, I want to delete them, but it says the file "Does not exist" which is the reason why I want to remove in the first place... because

  • How to adjust the date of transition of the slides in a slide show created in Windows Media Center

    I tried to set the time of transition from slides in a slide show using Windows Media Center. I went to the period of Transition, tasks, settings, photos and the value 3 (seconds, I presume). Saved settings. Burned DVD. Slides are still in transition

  • How to reset Windows 7 Home Premium services at default

    original title: Hello... is there a setting somewhere for services' default?... sp1 Windows 7 hp Hello.. is there a setting somewhere for services' default?... sp1 Windows 7 hp