Problem in query not getting desired output .

i have the following table
mysql> select * from emp;
+------+-------+--------+-------+
| eid  | ename | salary | depid |
+------+-------+--------+-------+
|   11 | ram   | 5000   | d1    |
|   22 | shyam | 3000   | d1    |
|   23 | mohan | 5500   | d2    |
|   44 | radha | 8000   | d3    |
|   48 | abhi  | 10000  | d3    |
+------+-------+--------+-------+
i am  executing  the following query :
mysql> select  depid,count(depid) from emp where salary >5100 group by depid;
and getting following result :
+-------+--------------+
| depid | count(depid) |
+-------+--------------+
| d2    |            1 |
| d3    |            2 |
+-------+--------------+
2 rows in set (0.00 sec)
i wants out put like this :
+-------+--------------+
| depid | count(depid) |
+-------+--------------+
 |d1    |            0 |
| d2    |            1 |
| d3    |            2 |
+-------+--------------+
thanks in advance .
csghanny.

Hi
csghanny,
You question seems to be wrong.
Because you are providing the filter condition where salary is greater than 5100. and for department d1, there is no salary more than 5100.
+------+-------+--------+-------+
| eid  | ename | salary | depid |
+------+-------+--------+-------+
|   11 | ram   | 5000   | d1    |
|   22 | shyam | 3000   | d1    |
|   23 | mohan | 5500   | d2    |
|   44 | radha | 8000   | d3    |
|   48 | abhi  | 10000  | d3    |
+------+-------+--------+-------+
select  depid, count(depid) from emp where salary >5100 group by depid;
so there is no chance that this query will return the output what you are expecting.
let us know, if you requirement is something different, so we can help you.
Please Mark as Answer if my post solved your problem or Vote As Helpful if this helps. Blogs: www.sqlserver2005forum.blogspot.com

Similar Messages

  • Not getting desired output

    declare
    v_sys number ;
    v_amt number ;
    dt date;
    cursor c is (select hcode,amt,EDATE,
    dense_rank() over(order by hcode)x from a );
    begin
    v_sys :=1 ;
    v_amt :=0 ;
    for var in c loop
    insert into b values(var.x,var.hcode);
    if (v_sys = var.x ) then
    v_amt := v_amt + var.amt ;
    else
    insert into c values(v_sys,v_amt,var.edate );
    v_amt := var.amt ;
    v_sys := var.x ;
    dt:=var.edate;
    end if ;
    end loop;
    insert into c values(v_sys,v_amt,dt );
    end;..All is well with this code except it returns the value of table b as:
    SQL> select * from b;
            ID      HCODE
             1         10
             1         10
             2         20
             2         20I need to get the output as:
    SQL> select * from b;
            ID      HCODE
             1         10
             2         20Any idea?
    Thanks

    Well, hcode = 10 and hcode = 20 both appear twice in the cursor you are walking through. The first thing you do after fetching a record is INSERT INTO b. Since there are two records in the cursor for hcode = 10, you get two records in b.
    I'm not entirely sure what you are trying to do here, but I suspect that you are rolling you own SUM for some reason. If so, then I think you need something more like:
    DECLARE
       v_sys NUMBER;
       v_amt NUMBER;
       dt    DATE;
       CURSOR c IS
          SELECT hcode, amt, edate, DENSE_RANK() OVER(ORDER BY hcode) x
          FROM a;
    BEGIN
       v_sys :=1;
       v_amt :=0;
       FOR var IN c LOOP
          IF (v_sys = var.x ) THEN
             v_amt := v_amt + var.amt;
          ELSE
             INSERT INTO c VALUES (v_sys, v_amt, var.edate);
             INSERT INTO b VALUES(var.x, var.hcode);
             v_amt := var.amt;
             v_sys := var.x;
             dt:=var.edate;
          END IF;
       END LOOP;
       INSERT INTO c values(v_sys,v_amt,dt );
    END;John

  • Query not giving desired output

    Hi
    I have the following values for the varchar column
    USR_UDF_STAFFID
    SEC/116     
    SEC/842     
    SEC/820     
    SEC/843     
    SEC/590     
    SEC/604     
    SEC/014     
    SEC/849     
    SEC/866
    SEC/601     
    SEC/602     
    SEC/1796     
    SEC/1888     
    SEC/444     
    SEC/167     
    SEC/760     
    SEC/885
    434532
    24244
    YC/3456
    YC/234
    CS/4512
    CS/345     
    I am running below query to get the max value.
    select max(usr_udf_staffid) as STAFF_ID from usr where usr_udf_staffid like 'SEC/%'
    Expected Output: SEC/1888     
    Actual Output: SEC/885
    What's wrong with this simple query?
    Pls help.

    hi Try this it will help
    SELECT       *
    FROM       usr
    ORDER BY  LPAD ( SUBSTR ( usr_udf_staffid
                   , 1
                   , INSTR (usr_udf_staffid, '/')
                , 5          -- Max. characters before the /
    ,       LPAD ( SUBSTR ( usr_udf_staffid
                   , 1 + INSTR (usr_udf_staffid, '/')
                , 10
                )          -- Max. characters after the /
    ;Regards
    Hitesh
    Edited by: Hitesh Nirkhey on Jan 6, 2011 4:47 PM

  • Not getting any output when running the Webservice through Xacute

    hai all,
    I am using a transaction as web service to be called in another transaction in the same server. I can see the output of the web service in the tracer, when I execute it in the BLS. But if I run the same transaction via xacute query I am not getting any output. I had read in one of the threads that reference document has to be assigned. I tried doing that also, but no luck. Can somebody pls. throw some light on how to use reference document & whether it is required in my case?
    Thanks,
    vidhya

    Hai Rick,
                    thanks for the hint i have used document and row actions now iam gettting output through xacute...
    thanks,
    vidhya.

  • "could not get an output file for the document (error RWI 00314)"

    Hi
    We are getting the following error when running the Webi Reports "could not get an output file for the document (error RWI 00314)". The issue seems to be related to Tomcat Memory Heap size, our Tomcat Java heap Size is 1024MB. We were able to resolve  the issue by restarting the Tomcat. We cannot restart the Tomcat in Prod if this is happening frequently.
    Can some one please suggest  any other solution other than restarting the Tomcat frequently, our platform is BOBJ XI 3.1 SP3 with FP 3.1 our Wndows OS is 32 Bit.
    Thank's for your help

    Hi Sreeram,
    Earlier i also faced same kind of problem.
    To solve this kind of problems you need to shutdown the server.
    second thing is when patches missed that time also you will get this kind of problem.
    check j2ee connection is it properly working or not?
    Regards,
    samar reddy.

  • I'm not getting proper output as per the Program

    Hi Experts,
             As i'm executing my ALV report regarding Customer Invoice on Production client I'm not getting proper output as per the program but when i execute the same report on Development client i'm getting proper output.
          Can anybody tell me how can i resolve this problem on production client? 
          Actually i've updated my report on my old report but still i'm getting old output of my report on production client, Program is showing updated code but at execution i'm getting old output.

    FORM Z_CREATE_FIELD_CATALOG.
    I_FCAT-FIELDNAME = 'BUKRS'.
      I_FCAT-HOTSPOT   = 'X'.
      I_FCAT-OUTPUTLEN = '00006'.
      I_FCAT-SELTEXT_L = 'Comp.Code'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
    I_FCAT-FIELDNAME = 'BELNR'.
    I_FCAT-HOTSPOT   = 'X'.
    I_FCAT-OUTPUTLEN = '000013'.
      I_FCAT-SELTEXT_L = 'Document No'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
    I_FCAT-FIELDNAME = 'KUNNR'.
    I_FCAT-HOTSPOT   = 'X'.
    I_FCAT-OUTPUTLEN = '000013'.
      I_FCAT-SELTEXT_L = 'Customer Code'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'NAME'.
    I_FCAT-HOTSPOT   = 'X'.
      I_FCAT-OUTPUTLEN = '000015'.
      I_FCAT-SELTEXT_L = 'Customer Name'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
    I_FCAT-FIELDNAME = 'GJAHR'.
    I_FCAT-HOTSPOT   = 'X'.
      I_FCAT-OUTPUTLEN = '000005'.
      I_FCAT-SELTEXT_L = 'Fscl.Yr'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'KOSTL'.
    I_FCAT-HOTSPOT   = 'X'.
      I_FCAT-OUTPUTLEN = '000008'.
      I_FCAT-SELTEXT_L = 'Cost Center'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'XBLNR'.
    I_FCAT-HOTSPOT   = 'X'.
    I_FCAT-OUTPUTLEN = '000016'.
      I_FCAT-SELTEXT_L = 'Invoice No'.
    I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
       I_FCAT-FIELDNAME = 'SGTXT'.
    I_FCAT-HOTSPOT   = 'X'.
      I_FCAT-OUTPUTLEN = '000015'.
      I_FCAT-SELTEXT_L = 'Item Text'.
    I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'BUDAT'.
    I_FCAT-OUTPUTLEN = '000015'.
      I_FCAT-SELTEXT_L = 'Posting Date'.
    I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'MWSKZ'.
    I_FCAT-HOTSPOT   = 'X'.
    I_FCAT-OUTPUTLEN = '0000010'.
      I_FCAT-SELTEXT_L = 'Tax Code'.
    I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'TAXTXT'.
    I_FCAT-HOTSPOT   = 'X'.
      I_FCAT-OUTPUTLEN = '0000015'.
      I_FCAT-SELTEXT_L = 'Tax Description'.
    I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
    I_FCAT-FIELDNAME = 'HKONT'.
    I_FCAT-HOTSPOT   = 'X'.
    I_FCAT-OUTPUTLEN = '000013'.
      I_FCAT-SELTEXT_L = 'G/L Account'.
    I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'WRBTR'.
    I_FCAT-OUTPUTLEN = '000018'.
      I_FCAT-SELTEXT_L = 'Net Amount'.
       I_FCAT-cfieldname    = 'PSWSL'.
      I_FCAT-DO_SUM = 'X'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
    I_FCAT-FIELDNAME = 'HKONT2'.
    I_FCAT-HOTSPOT   = 'X'.
    I_FCAT-OUTPUTLEN = '000013'.
      I_FCAT-SELTEXT_L = 'Tax G/L No.'.
    I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'WRBTR2'.
    I_FCAT-OUTPUTLEN = '000018'.
      I_FCAT-SELTEXT_L = 'Tax Amount'.
       I_FCAT-cfieldname    = 'PSWSL'.
      I_FCAT-DO_SUM = 'X'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
    I_FCAT-FIELDNAME = 'HKONT1'.
    I_FCAT-HOTSPOT   = 'X'.
    I_FCAT-OUTPUTLEN = '000013'.
      I_FCAT-SELTEXT_L = 'Freight G/L No'.
    I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'WRBTR1'.
    I_FCAT-OUTPUTLEN = '000018'.
      I_FCAT-SELTEXT_L = 'Freight Amount'.
       I_FCAT-cfieldname    = 'PSWSL'.
      I_FCAT-DO_SUM = 'X'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'GROSS'.
    I_FCAT-OUTPUTLEN = '000018'.
      I_FCAT-SELTEXT_L = 'Gross Amount'.
      I_FCAT-DO_SUM = 'X'.
       I_FCAT-cfieldname    = 'PSWSL'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'PSWSL'.
    I_FCAT-OUTPUTLEN = '000018'.
    I_FCAT-OUTPUTLEN = '000004'.
      I_FCAT-SELTEXT_L = 'Curr.'.
      I_FCAT-DO_SUM = 'X'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
    LS_SORT-UP = 'X'.
      LS_SORT-FIELDNAME = 'BELNR'.
        APPEND LS_SORT TO I_SORT.
        CLEAR LS_SORT.
    LAYOUT-ZEBRA = 'X'.
    ENDFORM.

  • Cosuming web service using consumer proxy - not getting the output

    Hello All,
    I am not getting the consumer proxy output structue filled though the web service is successfully executed. I did the following steps.
    1. Created a webservice form RFC BAPISDORDER_GETDETAILEDLIST
    2. Created a consumer proxy for the above created WSDL document.
    3. Tested the service by executing the proxy directly by feeding the input in the XML (sales document and partner view). it is working fine
    4. Created a program to access the consumer proxy by passing the input(same input as per XML). I am not getting the output in the proxy output structure ( but I can see the RFC is successfully executed and having the right values in the debugging mode).
    Is this the issue is due to the date fields (XML cannot consider a blank date )?
    Please note: the partner output table parameter in the bapi (output I am looking for ) is not having any date fields.
    Please help me to sort out this issue.
    Thanks,
    Gopi

    Hi Gopi,
    From your description, I assume you used the SE37 transaction's menu option Utilities -> More Utilities -> Create Web Service -> From the Function Module, to expose the BAPI concerned as a Web Service.
    If this is the case, then it is possible that you are falling foul of your SAP User ID not having the necessary Remote Function Call authorization to execute the BAPI.
    A prerequisite for successfully calling an RFC-enabled Function Module (which is what a BAPI is) is that the User ID used to call the function module must have the required RFC authorization (Authorization Object S_RFC).  For example, when calling function module BAPI_CUSTOMER_GET_ROOT, if the User ID lacks the requisite authorization in the target system, the following error message will be received by the Consuming application:
        User <User ID> has no RFC authorization for function group V02HBAPI.
    Notice, as you can see from the above message, RFC execution authorization is implemented at the Function Group level, not at the Function Module level.  In othere words, granting a user the authorization to a function group (authorization object S_RFC) enables the user to execute all RFC-enabled function modules contained within that function group.
    I am guessing the BAPI works for you in debug mode because you are not calling the BAPI remotely.
    Let me know if this helps.
    Best Regards,
    Andy.

  • Can I get a query to get the output data like 4th column instead of 3rd col

    Can I get a query to get the output data like 4th column instead of 3rd column ?
    SQL&gt; select emp.deptno, empno, rownum from emp, dept where emp.deptno=dept.deptno;
    DEPTNO EMPNO ROWNUM
    10 7782 *1* *1*
    10 7839 *2* *2*
    10 7934 *3* *3*
    20 7369 *4* *1*
    20 7876 *5* *2*
    20 7902 *6* *3*
    20 7788 *7* *4*
    20 7566 *8* *5*
    30 7499 *9* *1*
    30 7698 *10* *2*
    30 7654 *11* *3*
    30 7900 *12* *4*
    30 7844 *13* *5*
    30 7521 *14* *6*
    14 rows selected.

    SQL> select emp.deptno, emp.empno,
      2    row_number() over(order by emp.deptno, emp.empno) rn,
      3    row_number() over(partition by emp.deptno order by emp.empno) dept_rn
      4  from emp, dept
      5  where emp.deptno=dept.deptno
      6  order by emp.deptno, emp.empno;
        DEPTNO      EMPNO         RN    DEPT_RN
            10       7782          1          1
            10       7839          2          2
            10       7934          3          3
            20       7369          4          1
            20       7566          5          2
            20       7788          6          3
            20       7876          7          4
            20       7902          8          5
            30       7499          9          1
            30       7521         10          2
            30       7654         11          3
            30       7698         12          4
            30       7844         13          5
            30       7900         14          6
    14 rows selected.Regards,
    Dima

  • Why do we not get logging output for the clients?

    Q: Why do we not get logging output like #show log all | include <client mac address> for the wireless clients?
    A: When the clients connected to Bridge mode SSID, Firewall hits and logging does not work.  
    This is one of the limitations with bridge mode.  

    logical. fair. I can understand the confusion in policy  as another fine cloud service - DropBox - has a different model for increases in free storage amounts for one account = evangelism. As many policies as there are services probably.
    cya 'round o' kilted one
    CCC

  • I am not getting any output from the speakers of the ipad. However the sound is ok if i use headphones. Can anyone help?

    I am not getting any output from the speakers of the ipad. However the sound is ok if i use headphones. Can anyone help?

    1. Check the Side Switch
    http://i1224.photobucket.com/albums/ee374/Diavonex/00bf6eae.jpg
    2. Double-click the Home button and swipe to the right and check volume control
    http://i1224.photobucket.com/albums/ee374/Diavonex/ea5b842d.jpg
    3. Settings>Notification>Game Center>Sound>ON
    http://i1224.photobucket.com/albums/ee374/Diavonex/67a15edf.jpg

  • Format-number,decimal not giving desired output for PO Print report XSL-FO

    Hi All,
    My requirement was to get the Unit price in european format which is 10.000,00
    Iam getting it as 10000,00 but the client needs the thousand's seperator.
    if have used the decimal seperator but iam getting the Unit Price value as 'NAN' when i submit it for an international language like Italian or Spanish
    This is what i have done
    set the decimal format
    <xsl:decimal-format name="euro" decimal-separator="," grouping-separator="."/>
    <xsl:value-of select="format-number(UNIT_PRICE, '#.###,####', 'euro')"/>
    This gives the desired output when i select the US language.
    While submitting through the conc request
    If i change the Numeric char to '.,' by clickin on Language settings..It works great
    I have tried to use the replace function but the syntax is not correct
    format-number(replace('UNIT_PRICE',',','.'), '#.###.###.###,####', 'euro')
    Any Help would be greatly appreciated.
    Thanks
    Mirza

    Hi Mirza,
    I'm struggling having the same problem. Have you found any solution?
    Best regards
    Kenneth

  • Not getting proper output in .rtf format

    Hi all i m getting this output when running request with an rtf template.o am working with XML publisher 4.5 and have developed template in microsoft word.
    Here is the output
    %PDF-1.4
    5 0 obj
    <<
    /Type /Page
    /Parent 3 0 R
    /Resources 4 0 R
    /Contents 6 0 R
    /MediaBox[ 0 0 612.0 792.0 ]
    /CropBox[ 0 0 612.0 792.0 ]
    /Rotate 0
    >>
    endobj
    6 0 obj
    << /Length 155 /Filter /FlateDecode >>
    stream
    x¿m¿!¿¿¿w`<¿¿¿VO¿¿¿¿<Ù¿¿¿¿¿ ¿04)¿¿¿j¿¿Z¿¿¿¿!¿I¿*¿¿PB¿¿¿¿b{¿¿*¿¿¿¿¿¿¿¿-¿¿ü¿¿C¿&T¿¿ndstream
    endobj
    1 0 obj
    <<
    /Type /Catalog
    /Pages 3 0 R
    >>
    endobj
    2 0 obj
    <<
    /Type /Info
    /Producer (Oracle XML Publisher 4.5.0)
    >>
    endobj
    3 0 obj
    <<
    /Type /Pages
    /Kids [
    5 0 R
    /Count 1
    >>
    endobj
    4 0 obj
    <<
    /ProcSet [ /PDF /Text ]
    /Font <<
    /F0 7 0 R
    >>
    >>
    endobj
    7 0 obj
    <<
    /Type /Font
    /Subtype /Type1
    /BaseFont /Helvetica
    /Encoding /WinAnsiEncoding
    >>
    endobj
    8 0 obj
    [ 5 0 R /XYZ 84.6 604.4 null ]
    endobj
    xref
    0 9
    0000000000 65535 n
    0000000401 00000 n
    0000000456 00000 n
    0000000534 00000 n
    0000000602 00000 n
    0000000010 00000 n
    0000000168 00000 n
    0000000678 00000 n
    0000000783 00000 n
    trailer
    <<
    /Size 9
    /Root 1 0 R
    /Info 2 0 R
    /ID [<974c380ea692f8fdbdad4b9206bce756><974c380ea692f8fdbdad4b9206bce756>]
    >>
    startxref
    832
    %%EOF
    any idea
    naveen

    Your issue has nothing to do with upgrading to 5.0, it is a post script printer issue. That output that is printing to your printer is caused because PASTA is not setup correctly. You should be able to query Metalink for PASTA and get the proper setup steps.
    Brett

  • How to modify the query to get the output in a single row

    Hi All,
    Below is the query i have written it works fine
    select DISTINCT right(left(CTACCT,13),4) AS LocationNum,
    tODS_GLBalance.FiscalYearId AS FiscalYearId,
    tODS_GLBalance.FiscalMonthOfYearId AS FiscalMonthOfYearId,
    --tods_GLMetadata.Metric,
    Case when
    tods_GLMetadata.Metric = 'Gross Margin'
    Then SUM(Balance)
    Else 0
    END AS GrossMargin,
    Case when
    tods_GLMetadata.Metric = 'Occupancy'
    Then SUM(Balance)
    Else 0
    END AS Occupancy,
    Case when
    tods_GLMetadata.Metric = 'Payroll Dollars'
    Then SUM(Balance)
    Else 0
    END AS Payroll,
    Case when
    tods_GLMetadata.Metric = 'CF Sales'
    Then SUM(Balance)
    Else 0
    END AS OperatingSales,
    Case when
    tods_GLMetadata.Metric = 'Operations'
    Then SUM(Balance)
    Else 0
    END AS OperatingExpenses
    -- 0 as payroll
    from ods.[JJill].[tODS_GLBalance]
    inner join ods.Staging.tODS_INF_GLPCT ON tODS_GLBalance.PageNum = tODS_INF_GLPCT.CTPAGE
    inner join ods.JJill.tods_GLMetadata ON tods_GLMetadata.AcctDescription = tODS_INF_GLPCT.CTDESC
    where
    (tODS_GLBalance.FiscalYearId = 2012) and
    (tODS_GLBalance.FiscalMonthOfYearId = 2) and
    (right(left(CTACCT,13),4)= 3020)
    group by
    right(left(CTACCT,13),4),
    tODS_GLBalance.FiscalYearId,
    tODS_GLBalance.FiscalMonthOfYearId,
    tods_GLMetadata.Metric
    This is the sample output,
    LocationNum FiscalYearId FiscalMonthOfYearId GrossMargin Occupancy Payroll OperatingSales OperatingExpenses
    3020 2012 2 -112477.00 0.00 0.00 0.00 0.00
    3020 2012 2 0.00 0.00 0.00 -158288.94 0.00
    3020 2012 2 0.00 0.00 0.00 0.00 5625.44
    3020 2012 2 0.00 0.00 24185.79 0.00 0.00
    3020 2012 2 0.00 31075.53 0.00 0.00 0.00
    But, i am expecting the output to be something like this
    LocationNum FiscalYearId FiscalMonthOfYearId GrossMargin Occupancy Payroll OperatingSales OperatingExpenses
    3020 2012 2 -112477.00 31075.53 24185.79 -158288.94 5625.44
    Can someone please help me with changing my query to get the desired output?
    Please let me know if you have any questions.
    Thanks

    Try this:
    SELECT DISTINCT
    RIGHT(LEFT(CTACCT,13),4) AS LocationNum, tODS_GLBalance.FiscalYearId AS FiscalYearId, tODS_GLBalance.FiscalMonthOfYearId AS FiscalMonthOfYearId,
    SUM(CASE WHEN tods_GLMetadata.Metric = 'Gross Margin' THEN Balance ELSE 0 END ) AS GrossMargin,
    SUM(CASE WHEN tods_GLMetadata.Metric = 'Occupancy' THEN Balance ELSE 0 END ) AS Occupancy,
    SUM(CASE WHEN tods_GLMetadata.Metric = 'Payroll Dollars' THEN Balance ELSE 0 END ) AS Payroll,
    SUM(CASE WHEN tods_GLMetadata.Metric = 'CF Sales' THEN Balance ELSE 0 END ) AS OperatingSales,
    SUM(CASE WHEN tods_GLMetadata.Metric = 'Operations' THEN Balance ELSE 0 END ) AS OperatingExpenses
    FROM ods.[JJill].[tODS_GLBalance]
    INNER JOIN ods.Staging.tODS_INF_GLPCT
    ON tODS_GLBalance.PageNum = tODS_INF_GLPCT.CTPAGE
    INNER JOIN ods.JJill.tods_GLMetadata
    ON tods_GLMetadata.AcctDescription = tODS_INF_GLPCT.CTDESC
    WHERE tODS_GLBalance.FiscalYearId = 2012
    AND tODS_GLBalance.FiscalMonthOfYearId = 2
    AND RIGHT(LEFT(CTACCT,13),4) = 3020
    GROUP BY right(left(CTACCT,13),4), tODS_GLBalance.FiscalYearId, tODS_GLBalance.FiscalMonthOfYearId, tods_GLMetadata.Metric

  • In oracle Httpuritype - Not getting the output correctly

    Hi, I am trying out httpuritype in oracle for the first time. My requirement is to get the input string and the from_language and to_language and has to be converted accordingly.
    I am using oracle 11.2.0.1.
    So had setup acl explicitly and started writing the below program.
    create or replace procedure trans_new_prc1
    (p_words in varchar2, -- words to be translated
    p_to in varchar2 , -- language to translate to
    p_from in varchar2 ) -- language to translate from
    is
    l_res varchar2(2000);
    l_words varchar2(2000);
    txt varchar2(2000);
    begin
    txt:=utl_url.escape(l_words);
    l_words:=regexp_substr(httpuritype('http://translate.google.co.in/?hl=en&tab=wT#'||p_from||'/'||p_to|| txt).getclob(),'"(.*?)"',1,1,null,1);
    Dbms_output.put_line( l_words);
    end;
    While converting from polish language to english language I get the output as
    SQL> exec trans_new_prc1('hen','pl','en');
    text/html; charset=ISO-8859-2
    But i need the exact string in polish language, which i am not getting. Please guide me.
    Even while converting it into chinese language, i get the following message
    SQL> exec trans_new_prc1('hen','zh-CN','en');
    text/html; charset=ISO-8859-2
    Please guide me to get the output exactly in chinese language.

    I think the problem is, google translate is not giving that info with this URL ! I removed REGEXP_SUBSTR and get all html code from HTTPURITYPE, in returned code, there is no translated word info!
    for the code
      exec trans_new_prc1('hen','ENGLISH','AUTO');result is:
    <!DOCTYPE html><html><head><meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><meta name=keywords content="translate, translations, translation, translator, machine translation, online translation"><meta name=description content="Google's free online language translation service instantly translates text and web pages. This translator supports: English, Afrikaans, Albanian, Arabic, Armenian, Azerbaijani, Basque, Belarusian, Bengali, Bulgarian, Catalan, Chinese, Croatian, Czech, Danish, Dutch, Esperanto, Estonian, Filipino, Finnish, French, Galician, Georgian, German, Greek, Gujarati, Haitian Creole, Hebrew, Hindi, Hungarian, Icelandic, Indonesian, Irish, Italian, Japanese, Kannada, Korean, Latin, Latvian, Lithuanian, Macedonian, Malay, Maltese, Norwegian, Persian, Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovenian, Spanish, Swahili, Swedish, Tamil, Telugu, Thai, Turkish, Ukrainian, Urdu, Vietnamese, Welsh, Yiddish"><meta name=robots content=noodp><meta name=google content=notranslate><link rel="canonical" href="http://translate.google.com/"><title>Google Translate</title><link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml?hl=en" title="Google Translate"><script>function _gtErr(e){var i=new Image();i.src='/gen204?jserr='+encodeURIComponent(e+": "+e.stack).substr(0,2000);i.onload=function(){i.onload=null;};}window.onerror=_gtErr;</script><script>(function(){var ti_a=function(b){this.t={};this.tick=function(b,c,a){a=void 0!=a?a:(new Date).getTime();this.t=[a,c]};this.tick("start",null,b)},ti_b=new ti_a;window.jstiming={Timer:ti_a,load:ti_b};if(window.performance&&window.performance.timing){var ti_c=window.performance.timing,ti_d=window.jstiming.load,ti_e=ti_c.navigationStart,ti_f=ti_c.responseStart;0<ti_e&&ti_f>=ti_e&&(ti_d.tick("_wtsrt",void 0,ti_e),ti_d.tick("wtsrt_","_wtsrt",ti_f))}
    there is no "THEM" (translated word) in it.  (I couldnt write whole returned info because exceed post limits.)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • VO  query not getting executed

    Hi,
    I am facing a problem in executing the query of my extended VO. I have extended a VO and modified the query in the extended VO to fetch two more columns from the database.
    Now I am trying to execute the query of my extended VO. But I do not get any results. I think the query execution is not happening. Please go through the code mentioned below :
    1. OAViewObject oaviewobject1 = (OAViewObject)
    2. oaapplicationmodule.findViewObject("XXAIBidHeadersSPVO1");
    3. oaviewobject1.reset();
    4. oaviewobject1.setWhereClauseParams(null);
    5. oaviewobject1.setWhereClauseParam(0, negotiationvorowimpl.getAuctionHeaderId());
    6. oaviewobject1.executeQuery();
    7. XXAIBidHeadersSPVORowImpl rowImpl = (XXAIBidHeadersSPVORowImpl) oaviewobject1.first();
    8. System.out.println("Value of rowImpl = " + rowImpl);
    9. System.out.println("Value of SSI flag = " + rowImpl.getSsi());
    10. System.out.println("Value of PSU flag = " + rowImpl.getPsu());
    The execution stops after line 8. I am not able to get the values of the two new columns included in the where clause. Please advise as to what might be going wrong. This is very urgent.
    Thanks and Regards,
    Sandhya

    If vo.first returns you an object, means your query is executed and there is a row in the ViewObject, if 9 and 10 are displaying null, this means there is a row where these columns are without values.
    Try doing this
    Run the page in debug mode, you will see plenty of data in the log window, the query that is executed and the bind values will also be there, take this query and run it in sqlplus, check if the results are consistent.
    Thanks
    Tapash

Maybe you are looking for