Need Desired Output

HELLO EVERYONE,
PLZ HELP ME WITH THE BELOW QUERY.
THE BELOW CONDTION SHOULD BE APPLIED FOR THE DATA
CASE COUNT (MAX(ADATE) )
               WHEN 1 THEN '15'
               WHEN 2 THEN '30'
               WHEN 3 THEN '60'
               WHEN 4 THEN '120'
END
_SAMPLE OUTPUT_
V104       30
V105       15
V107       60
V249       120
V272      15
TABLE T1 AS (AID,ANO,ADATE)
INSERT INTO T1 ( AID, ANO, ADATE ) VALUES (
664604, 'V104',  TO_Date( '12/31/2011 10:20:45 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO T1 ( AID, ANO, ADATE ) VALUES (
664603, 'V104',  TO_Date( '12/31/2011 10:20:45 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO T1 ( AID, ANO, ADATE ) VALUES (
664602, 'V104',  TO_Date( '03/13/2012 07:34:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO T1 ( AID, ANO, ADATE ) VALUES (
664601, 'V104',  TO_Date( '03/13/2012 07:34:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO T1 ( AID, ANO, ADATE ) VALUES (
664604, 'V105',  TO_Date( '12/31/2011 10:20:45 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO T1 ( AID, ANO, ADATE ) VALUES (
664603, 'V105',  TO_Date( '12/31/2011 10:20:45 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO T1 ( AID, ANO, ADATE ) VALUES (
664602, 'V105',  TO_Date( '12/31/2011 10:20:45 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO T1 ( AID, ANO, ADATE ) VALUES (
664601, 'V105',  TO_Date( '03/25/2012 01:19:00 PM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO T1 ( AID, ANO, ADATE ) VALUES (
664604, 'V107',  TO_Date( '12/31/2011 10:20:45 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO T1 ( AID, ANO, ADATE ) VALUES (
664603, 'V107',  TO_Date( '03/24/2012 01:38:00 PM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO T1 ( AID, ANO, ADATE ) VALUES (
664602, 'V107',  TO_Date( '03/24/2012 01:38:00 PM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO T1 ( AID, ANO, ADATE ) VALUES (
664601, 'V107',  TO_Date( '03/24/2012 01:38:00 PM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO T1 ( AID, ANO, ADATE ) VALUES (
664604, 'V249',  TO_Date( '03/03/2012 07:09:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO T1 ( AID, ANO, ADATE ) VALUES (
664603, 'V249',  TO_Date( '03/03/2012 07:09:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO T1 ( AID, ANO, ADATE ) VALUES (
664602, 'V249',  TO_Date( '03/03/2012 07:09:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO T1 ( AID, ANO, ADATE ) VALUES (
664601, 'V249',  TO_Date( '03/03/2012 07:09:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO T1 ( AID, ANO, ADATE ) VALUES (
664598, 'V272',  TO_Date( '12/31/2011 10:20:44 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO T1 ( AID, ANO, ADATE ) VALUES (
664597, 'V272',  TO_Date( '02/19/2012 08:06:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO T1 ( AID, ANO, ADATE ) VALUES (
664596, 'V272',  TO_Date( '03/25/2012 02:04:00 PM', 'MM/DD/YYYY HH:MI:SS AM'));
COMMIT;

Hi,
H.O wrote:
... Well, thanks. That would work. however, my table t1 is not a simple one. can this be achieved by analytical fn's in a simple way, to avoid using the table t1 twice?Instead of hiding some of your requirements, then waiting for a unsuitable answer and then complaining about it, consider giving all of your requirements in your first message.
Here's a way to get the same results only referencing the t1 table once:
WITH     got_r_num     AS
     SELECT       ano
     ,       adate
     ,       CASE  COUNT (*)
                      WHEN  1  THEN   15
                      WHEN  2  THEN   30
                      WHEN  3  THEN   60
                      WHEN  4  THEN  120
            END               AS cnt
     ,       RANK () OVER ( PARTITION BY  ano
                             ORDER BY      adate  DESC  NULLS LAST
                      )      AS r_num
     FROM      t1
     GROUP BY  ano
     ,            adate
SELECT    ano
,       adate          -- if wanted
,       cnt
FROM       got_r_num
WHERE       r_num     = 1
ORDER BY  ano
;It's unclear if this will be faster or slower than what I originally posted. Even though only one scan of the t1 table is required, the analytic function means that the result set of the GROUP BY has to be scanned, which could be even slower.

Similar Messages

  • 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

  • Report is executing in background and need data(output) in excel format

    Report is executing in background and need data(output) to get downloaded in excel format in my PC from an internal table;;in any drive i.e. C: or D: .When executing in backround it prompt to user with which location excel file to be saved and the name of file.How to download in background in excel format?
    Edited by: PRASHANT BHATNAGAR on Aug 26, 2008 6:24 AM

    Hi
    Download a report to excel with format (border, color cell, etc)
    Try this program...it may help you to change the font ..etc.
    Code:
    REPORT ZSIRI NO STANDARD PAGE HEADING.
    this report demonstrates how to send some ABAP data to an
    EXCEL sheet using OLE automation.
    INCLUDE OLE2INCL.
    handles for OLE objects
    DATA: H_EXCEL TYPE OLE2_OBJECT,        " Excel object
          H_MAPL TYPE OLE2_OBJECT,         " list of workbooks
          H_MAP TYPE OLE2_OBJECT,          " workbook
          H_ZL TYPE OLE2_OBJECT,           " cell
          H_F TYPE OLE2_OBJECT.            " font
    TABLES: SPFLI.
    DATA  H TYPE I.
    table of flights
    DATA: IT_SPFLI LIKE SPFLI OCCURS 10 WITH HEADER LINE.
    *&   Event START-OF-SELECTION
    START-OF-SELECTION.
    read flights
      SELECT * FROM SPFLI INTO TABLE IT_SPFLI UP TO 10 ROWS.
    display header
      ULINE (61).
      WRITE: /     SY-VLINE NO-GAP,
              (3)  'Flg'(001) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (4)  'Nr'(002) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (20) 'Von'(003) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (20) 'Nach'(004) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (8)  'Zeit'(005) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP.
      ULINE /(61).
    display flights
      LOOP AT IT_SPFLI.
      WRITE: / SY-VLINE NO-GAP,
               IT_SPFLI-CARRID COLOR COL_KEY NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CONNID COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CITYFROM COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CITYTO COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-DEPTIME COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP.
      ENDLOOP.
      ULINE /(61).
    tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-007
           EXCEPTIONS
                OTHERS     = 1.
    start Excel
      CREATE OBJECT H_EXCEL 'EXCEL.APPLICATION'.
    PERFORM ERR_HDL.
      SET PROPERTY OF H_EXCEL  'Visible' = 1.
    CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'c:\kis_excel.xls'
    PERFORM ERR_HDL.
    tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-008
           EXCEPTIONS
                OTHERS     = 1.
    get list of workbooks, initially empty
      CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
      PERFORM ERR_HDL.
    add a new workbook
      CALL METHOD OF H_MAPL 'Add' = H_MAP.
      PERFORM ERR_HDL.
    tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-009
           EXCEPTIONS
                OTHERS     = 1.
    output column headings to active Excel sheet
      PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
      PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
      PERFORM FILL_CELL USING 1 3 1 'Von'(003).
      PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
      PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
      LOOP AT IT_SPFLI.
    copy flights to active EXCEL sheet
        H = SY-TABIX + 1.
        PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
        PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
        PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
        PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
        PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
      ENDLOOP.
    changes by Kishore  - start
    CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
      CALL METHOD OF H_EXCEL 'Worksheets' = H_MAPL." EXPORTING #1 = 2.
      PERFORM ERR_HDL.
    add a new workbook
      CALL METHOD OF H_MAPL 'Add' = H_MAP  EXPORTING #1 = 2.
      PERFORM ERR_HDL.
    tell user what is going on
      SET PROPERTY OF H_MAP 'NAME' = 'COPY'.
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-009
           EXCEPTIONS
                OTHERS     = 1.
    output column headings to active Excel sheet
      PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
      PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
      PERFORM FILL_CELL USING 1 3 1 'Von'(003).
      PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
      PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
      LOOP AT IT_SPFLI.
    copy flights to active EXCEL sheet
        H = SY-TABIX + 1.
        PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
        PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
        PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
        PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
        PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
      ENDLOOP.
    changes by Kishore  - end
    disconnect from Excel
         CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING  #1 = 'C:\SKV.XLS'.
      FREE OBJECT H_EXCEL.
      PERFORM ERR_HDL.
          FORM FILL_CELL                                                *
          sets cell at coordinates i,j to value val boldtype bold       *
    FORM FILL_CELL USING I J BOLD VAL.
      CALL METHOD OF H_EXCEL 'Cells' = H_ZL EXPORTING #1 = I #2 = J.
      PERFORM ERR_HDL.
      SET PROPERTY OF H_ZL 'Value' = VAL .
      PERFORM ERR_HDL.
      GET PROPERTY OF H_ZL 'Font' = H_F.
      PERFORM ERR_HDL.
      SET PROPERTY OF H_F 'Bold' = BOLD .
      PERFORM ERR_HDL.
    ENDFORM.
    *&      Form  ERR_HDL
          outputs OLE error if any                                       *
    -->  p1        text
    <--  p2        text
    FORM ERR_HDL.
    IF SY-SUBRC <> 0.
      WRITE: / 'Fehler bei OLE-Automation:'(010), SY-SUBRC.
      STOP.
    ENDIF.
    ENDFORM.                    " ERR_HDL
    Regards
    Murali Papana

  • I need to output a PAL HDV project from FCP as a PAL DV file with 4 audio t

    I need to output a PAL HDV project from FCP as a PAL DV file with 4 audio tracks - specifically one stereo pair to be t1&t3, the other stereo pair to be t2&t4. This is the standard way requested by an international distributor of tv programmes. I understand how to set the sequence in FCP to output 4 audio tracks - either 2 stereo pairs (1&2, + 3&4), or 4 discrete tracks. But how do I then output this as a QT file?
    The manual tells me that to export multiple audio tracks, File>Export>QT Movie has it's Config pop-up menu in the Audio Settings area of the General tab of the Sequence Settings. Well, that's set for 4 discrete channels, but the QT export settings only allow for 2 mono or 1 stereo output, and that's what I get when I try it. What it says in the manual just doesn't happen.
    Exporting via Compressor, on the other hand, has an abundance of choices of 4-track outputs, none of which are labelled as anything resembling 'discrete'. Would any of those 4.0 settings suffice? Or am I likely to get myself into difficulties further down the line? As I am monitoring for this task on a 2-track audio system, I cannot confirm exactly what I am getting when I use any of those settings.
    Any advice would be greatly appreciated!
    John

    Call me naive, but I've not heard of splitting the stereo pairs like this before.
    What broadcaster? (perhaps one of our EU regulars will drop in...)
    You can do all sorts of pairing but it is coincident tracks pairing- eg 1/2 + 3/4
    Sorry I can't offer anything.
    x

  • Need smartform output in different languages

    Hi expert,
    Can you please let me know how can I see the output of a smartform in different languages. I'm seeing the output of a sales order. I have three output types . ZZAC,ZZ00, ZZ01. The smarform is developed with the language attributes of Translate into all languages. Is it required to convert the forms in SE63? or there are other ways we can see it.
    I need the output in all the languages like FR,EN,DE,IT,ES ,EN etc.
    Thanks in Advance,
    Abhi

    HI,
    Try This... hope it will solve your problem....
    To maintain the translations:
    1. Go to transaction SE63 in R/3. Go to menu Translation->R/3 Enterprise->Other Long Texts.
    2. Select the object type in the pop up. Smartform (SSF) object type is found under Forms and Styles(FS).
    3. Enter the name of the Smart form and choose the source and target language(Let the Source Language be 'EN'). Now Click on 'EDIT'.
    4. This would open a screen with the Smartform code in Source language on the top and an editor with the same code in the bottom. Find the text for which you need to maintain the translation and insert the translation in that place.
    As usual after required texts are maintained Save and Activate.
    To see the translated Smartform create an output type and assign the smartform and the driver program to this output type. In the transaction that sends output to this smartform, select the output type and select the language in which the smartform has to be displayed (translations have to be maintained in this language).This will give the smartform in the required language.
    Regards,
    Shri

  • Proxy To file scenario : need the output in hierarchial structure

    Hi all,
    I am doing a proxy to file scenario. Now I am getting the output as :
    <documents>
    <document>
    <header>
    <delivery_number></delivery_number>
    <tax_number/>
    u2026
    </header>
    <data>
    u2026
    </data>
    </document>
    <document>
    <header>
      u2026
    </header>
    <data>
       u2026
    </data>
    </document>
    u2026
    </documents>
    But I would like to change the output to below structure.
    <documents>
               <document>
         <header>
                                 <delivery_number></delivery_number>
                                 <tax_number/>
                                  u2026
                         </header>
         <data>
                                     u2026
                          </data>
               </document>
               <document>
         <header>
                                 u2026
                          </header>
         <data>
                                u2026
                         </data>
                 </document>
    u2026
    </documents>
    Can anyone suggest me how can I get this?
    Thanks,
    Arivarasu S
    Edited by: Arivarasu S on Jan 31, 2011 2:54 PM
    Edited by: Arivarasu S on Jan 31, 2011 3:00 PM

    <documents>
          <document>
                <header>
                           <delivery_number></delivery_number>
                            <tax_number/>
                                      u2026
                 </header>
                 <data>
                            u2026
                  </data>
           </document>
    </documents>
    I need the output as mentioned above.. pls let me know how can i achieve this..
    Thanks,
    Arivarasu S
    Edited by: Arivarasu S on Jan 31, 2011 6:59 PM

  • Regarding Sements Mapping for desired output

    HI All,
    I am just confused how to handle this
    I have two source segments E1EDL37, E1EDL44 and Target IBINPT00
    all 3 segments occurence is 0...9999
    So for each occurence of E1EDL37 n no of sements repeat for E1EDL44(is in E1EDL37 only) and mapped to IBINPT00
    I have mapped E1EDL44 segment and fields to IBINPT00 and also E1EDL37 fields to IBINPT00 fields
    Now when i run the scenario i am getting the output like this
    0000214031   00007205170000000224  1000 1000  GN602  5190     9H     
                    1000  1000  GN602  GN602  6H 00002
                 1000  1000  GN602  GN602  7      00003
                 1000  1000  GN602  GN602  7H 00004
                 1000  1000  GN602  GN602  8     00005
    But i should get the output like this
    <b>0000214031  00007205170000000224</b>  1000  1000  GN602 5190     9H
    <b>0000214031  00007205170000000224</b>  1000  1000  GN602 5190     6H
    <b>0000214031  00007205170000000224</b>  1000  1000  GN602 5190     7
    <b>0000214031  00007205170000000224</b>  1000  1000  GN602 5190     7H
    So each fields of E1EDL37(has 1st and 2nd field) also should be repeated with the no of segments for E1EDL44 to target IBINPT00
    So any one please give suggestion on how to handle the desired output
    Thanks and Regards,
    sridhar

    Hi Himadri,
    I have used useOneAsMany node function but now i am not getting any values to the target...
    I have used like this
    E1EDL37,EXIDV,EXIDV to useOneAsMany --> SplitByValue > IBINPT00>IDVOL(target filed)...
    I am not getting the values now at all why? could u help me
    <b>Note</b> E1EDL37 (occurence is 0..9999) , EXIDV occurence (0.1) IDVOL (0.1)
    Thanks and Regards,
    sridhar

  • Need to output # of rows after date

    This seems like it probably has a simple solution that I just
    can't seem to get correct...
    I need to output the next 4 events that take place from the
    current date. I tried:
    <cfloop from="1" to="4" index="i">
    <cfif #DateFormat(games.gamedate)# GTE
    #DateFormat(Now())#>
    all the info that is displayed here
    </cfif>
    </cfloop>
    However this is just returning all the games that take place
    from the current date, and lists each game 4 times. I also tried
    putting maxrows="4" in my <cfoutput> statement, but that
    returns nothing.
    Any and all help is much appreciated.

    here's the entire block of code (minus the references to
    getting the next 4 records...this works but just lists all games
    from today on out):
    <cfquery name="athgames" datasource="#dsn#"
    username="#db_user#" password="#db_pass#" dbtype="query">
    SELECT *
    FROM Athletics
    WHERE sport = 'Basketball'
    ORDER BY gamedate ASC
    </cfquery>
    <cfset endofweek = dateAdd("d", +6, now())>
    <cfoutput query="athgames" group="gamedate">
    <cfif #DateFormat(athgames.gamedate)# GTE
    #DateFormat(Now())#>
    <cfif #DateFormat(athgames.gamedate)# EQ
    #DateFormat(Now())#>
    <p><u>Today's Games</u><br />
    <cfelse>
    <p><u>#DateFormat(athgames.gamedate, "dddd, mmmm
    d")#</u><br />
    </cfif>
    <cfoutput>
      #athgames.homeaway#
    #athgames.opponent# -
    <cfif #TimeFormat(athgames.gametime, "h:mm")# EQ
    #TimeFormat("12:59 AM", "h:mm")#>
    TBA
    <cfelse>
    #TimeFormat(athgames.gametime,"h:mm tt")#<br />
    </cfif>
    </cfoutput>
    </p>
    </cfif>
    </cfoutput>

  • How to get the desire output from sql query

    Consider an Order Table: ...
    Order Table:
    Order Id Item Qty
    O1 A1 5
    O2 A2 1
    O3 A3 3
    Please provide SQL which will explode the above data into single unit level records as shown below
    Desired Output:
    Order Id Order Id Qty
    O1 A1 1
    O1 A1 1
    O1 A1 1
    O1 A1 1
    O1 A1 1
    O2 A2 1
    O3 A3 1
    O3 A3 1
    O3 A3 1

    How do I ask a question on the forums?
    SQL and PL/SQL FAQ

  • How to set Back ground job & get my desired output layout in sm36 & sm37 ?

    Hai SAP ABAP/BASIS Gurus,
    I am currently taking ME2N PO Pending value Report by setting variant in input screen & setting my own output layout  ie only four field ie.Plant, Material,Currency,Still to be delivered value will be visible in output screen
    I set Back ground in sm36 using my variant & i saw my output in sm37.. But I cant get output as my desired field..
    This is my problem..
    1) I Cant Get the Same output in shedule job [sm36 & sm37] like When i run in foreground for ME2n.
        I am using ALV Scope of list..
    2) If I use BEST Layout in Scope of list means i get the desired Output field layout as same as my foreground output field..
    I want to get the output layout as desired & also in ALV format[ Useful for excel work]
    Kindly guide me.
    Thanks in advance..
    swetha
    Edited by: Swetha SAP Girl on Jul 2, 2009 5:06 PM

    Hi Swetha,
    To get the missed fields in the spool, while creating the background job(execute in background option) you can see the printer setting block at the end of the background job settings window, in that check the 'Spool Request Max. Width 255 char' check box and then continue. It will generate the spool list with maximum width and you can see all the fields in the spool output.
    Thanks,
    Muthu
    Edited by: Muthu Prabakaran Selvam on Jul 3, 2009 2:35 PM

  • Getting the desired Output

    Hi ALl,
    I have a table as Listed below.
    SQL> CREATE  TABLE T1 (c1 varchar2(10),c2 varchar2(10),c3 varchar2(10), c4 var
    ar2(10),audit1 number);
    Table created.
    SQL> DESC T1
    Name                                      Null?    Type
    C1                                                 VARCHAR2(10)
    C2                                                 VARCHAR2(10)
    C3                                                 VARCHAR2(10)
    C4                                                 VARCHAR2(10)
    AUDIT1                                             NUMBER
    SQL> INSERT INTO T1 VALUES('A','B',NULL,2,1);
    1 row created.
    SQL> INSERT INTO T1 VALUES('A','B',1,NULL,1);
    1 row created.
    SQL> COMMIT;
    Commit complete.
    SQL> SELECT * FROM T1;
    C1         C2         C3         C4             AUDIT1
    A          B                     2                   1
    A          B          1                              1
    SQL>I need to output from the above table as single row considering the Dupilcate values as once row ,and also nned to neglect the Null values from it and take the other possible value in it.
    C1         C2         C3         C4             AUDIT1
    A          B           1          2                   1

    Suppose a new row(below) is added, what do you expect as o/p?
    INSERT INTO T1 VALUES('A','B',1,3,2);Purvesh's query will give you the <tt>MAX(c4)</tt> but if you use <tt>SUM(c4)</tt> it'll also give you a single-row & NULLS removed but the values summed.
    -- "Query 1"
    select c1, c2, max(c3) c3, max(c4) c4, max(audit1) audit1
      from t1
    group by c1, c2;
    A     B     1     3     2
    -- "Query 2"
    select c1, c2, SUM(c3) c3, SUM(c4) c4, SUM(audit1) audit1
      from t1
    group by c1, c2;
    A     B     3     7     6Please clarify this.

  • Need report output same as its show in the previewer in the (.txt and .xls) format

    I need an output file(in text and excel format) generated from the report builder exactly in same format as it shows in the Report previewer.
    it should include all the labels as well as the data.
    Thanx in advance
    Reply ASAP
    From
    Dharmendra

    Hi Dharam
    You can create text file output as seen on Live Previewer by generating to Text (File->Generate to File->Text). Ensure that you run Builder with the following command line parameter:
    MODE=CHARACTER
    If the Builder mode is not character (BITMAP), it will generate PostScript file if you do a File->Generate to File->Text.
    You can create Excel format output from Reports with Delimited output (File->Generate to File->Delimited). In the ensuing dialog box, choose comma (,) as the delimiter to obtain a CSV file. Export this file in Excel.
    Regards
    The Oracle Reports Team

  • How to join to column details to get desired output

    Kindly refer the attached queries namely
    1)REORDER
    2)PENDING WORKORDER
    I want to calculate the work order requirement on basis of
    Stock, Pending sales order, re-order level and already entered workorders. Now i want to add the first column of 2nd query in the report of 1st query. For that i tried the below statements
    AND ITEM_CODE = LCS_ITEM_CODE (+)
    AND ITEM_CODE = SOI_ITEM_CODE (+)
    AND ITEM_CODE = PWH_ITEM_CODE (+)
    LCS_ITEM_CODE is Stock table item_code,
    SOI_ITEM_CODE is Sales order item_code,
    PWH_ITEM_CODE is Production work order item_code,
    When the above statments used while combining the 2 queries does display the result, but the details comes only for the ietm_codes whose work orders are present.
    Kindly guide me how can i get the desired output.
    1)RE-ORDER QUERY :
    SELECT DISTINCT ITEM_CODE,
    ITEM_NAME,
    (CASE
    WHEN SUBSTR(ITEM_CODE,11,3) = '000' THEN 'LOOSE'
    ELSE SUBSTR(ITEM_CODE,11,4)
    END) PKG_SIZE,
    ((LCS_STK_QTY_BU + LCS_RCVD_QTY_BU - LCS_ISSD_QTY_BU) / IU_MAX_LOOSE_1) * TO_NUMBER(SUBSTR(ITEM_CODE,- 3,3))
    ||DECODE(SUBSTR(LCS_ITEM_CODE,11,3),'000',((LCS_STK_QTY_BU + LCS_RCVD_QTY_BU - LCS_ISSD_QTY_BU) / IU_MAX_LOOSE_1)) STOCK,
    (CASE
    WHEN SUM(TO_NUMBER(SOI_QTY
    ||'.'
    ||SOI_QTY_LS) - (SOI_INVI_QTY_BU / IU_CONV_FACTOR / IU_MAX_LOOSE_1)) < 0 THEN 0
    ELSE SUM(TO_NUMBER(SOI_QTY
    ||'.'
    ||SOI_QTY_LS) - (SOI_INVI_QTY_BU / IU_CONV_FACTOR / IU_MAX_LOOSE_1))
    END) PNDG,
    ((LCS_STK_QTY_BU + LCS_RCVD_QTY_BU - LCS_ISSD_QTY_BU) / IU_MAX_LOOSE_1) * TO_NUMBER(SUBSTR(ITEM_CODE,- 3,3))
    ||DECODE(SUBSTR(LCS_ITEM_CODE,11,3),'000',((LCS_STK_QTY_BU + LCS_RCVD_QTY_BU - LCS_ISSD_QTY_BU) / IU_MAX_LOOSE_1)) - SUM(TO_NUMBER(SOI_QTY
    ||'.'
    ||SOI_QTY_LS) - (SOI_INVI_QTY_BU / IU_CONV_FACTOR / IU_MAX_LOOSE_1)) NETSTK,
    ITEM_RORD_LVL REORD_LVL,
    (CASE
    WHEN ((LCS_STK_QTY_BU + LCS_RCVD_QTY_BU - LCS_ISSD_QTY_BU) / IU_MAX_LOOSE_1) * TO_NUMBER(SUBSTR(ITEM_CODE,- 3,3))
    ||DECODE(SUBSTR(LCS_ITEM_CODE,11,3),'000',((LCS_STK_QTY_BU + LCS_RCVD_QTY_BU - LCS_ISSD_QTY_BU) / IU_MAX_LOOSE_1)) - SUM(TO_NUMBER(SOI_QTY
    ||'.'
    ||SOI_QTY_LS) - (SOI_INVI_QTY_BU / IU_CONV_FACTOR / IU_MAX_LOOSE_1)) > 0
    AND ITEM_RORD_LVL > 0 THEN ((LCS_STK_QTY_BU + LCS_RCVD_QTY_BU - LCS_ISSD_QTY_BU) / IU_MAX_LOOSE_1) * TO_NUMBER(SUBSTR(ITEM_CODE,- 3,3))
    ||DECODE(SUBSTR(LCS_ITEM_CODE,11,3),'000',((LCS_STK_QTY_BU + LCS_RCVD_QTY_BU - LCS_ISSD_QTY_BU) / IU_MAX_LOOSE_1)) - SUM(TO_NUMBER(SOI_QTY
    ||'.'
    ||SOI_QTY_LS) - (SOI_INVI_QTY_BU / IU_CONV_FACTOR / IU_MAX_LOOSE_1))
    ELSE NVL(ITEM_RORD_LVL,0) - (((LCS_STK_QTY_BU + LCS_RCVD_QTY_BU - LCS_ISSD_QTY_BU) / IU_MAX_LOOSE_1) * TO_NUMBER(SUBSTR(ITEM_CODE,- 3,3))
    ||DECODE(SUBSTR(LCS_ITEM_CODE,11,3),'000',((LCS_STK_QTY_BU + LCS_RCVD_QTY_BU - LCS_ISSD_QTY_BU) / IU_MAX_LOOSE_1)) - SUM(TO_NUMBER(SOI_QTY
    ||'.'
    ||SOI_QTY_LS) - (SOI_INVI_QTY_BU / IU_CONV_FACTOR / IU_MAX_LOOSE_1)))
    END) REQ,
    DECODE(ITEM_RORD_QTY_LS,NULL,ITEM_RORD_QTY,
    (ITEM_RORD_QTY
    ||'.'
    ||ITEM_RORD_QTY_LS)) BTCHSZE
    FROM OM_ITEM,
    OT_SO_HEAD,
    OT_SO_ITEM,
    OM_ITEM_UOM,
    OS_LOCN_CURR_STK
    WHERE (ITEM_UOM_CODE = IU_UOM_CODE
    AND ITEM_CODE = IU_ITEM_CODE)
    AND ITEM_CODE = LCS_ITEM_CODE (+)
    AND ITEM_CODE = SOI_ITEM_CODE (+)
    AND LCS_LOCN_CODE = 'FG'
    AND LCS_ITEM_CODE = SOI_ITEM_CODE
    AND SOI_SOH_SYS_ID = SOH_SYS_ID
    AND SOH_TXN_CODE IN ('SORLLOC',
    'SORLCT3',
    'SORLNPL',
    'EXPFABLK')
    AND NVL(SOH_CLO_STATUS,0) = 0
    AND NVL(SOI_SHORT_CLO_STATUS,2) = 2
    GROUP BY ITEM_CODE,
    ITEM_NAME,
    LCS_STK_QTY_BU,
    LCS_RCVD_QTY_BU,
    LCS_ISSD_QTY_BU,
    IU_MAX_LOOSE_1,
    ITEM_RORD_LVL_LS,
    ITEM_RORD_LVL,
    ITEM_RORD_QTY_LS,
    ITEM_RORD_QTY,
    LCS_ITEM_CODE
    ORDER BY ITEM_CODE ASC
    2) WORK-ORDERS QUERY :
    SELECT DISTINCT PWH_NO PWO_NO,
    PWH_DT PWO_DT,
    (CASE
    WHEN PWFGPI_QTY = 0 THEN PWH_ITEM_CODE
    ELSE PWFGPI_ITEM_CODE
    END) ITEMCODE,
    ITEM_NAME PRODUCT_NAME,
    (CASE
    WHEN PWFGPI_QTY = 0 THEN SUM(PWH_QTY)
    ELSE PWFGPI_QTY * SUBSTR(PWFGPI_ITEM_CODE,11,3)
    END) PWO_QTY,
    PSD_PR_ACCP_QTY_BU / 1000 PROD_REP,
    PWH_PS_QTY_BU / 1000 PROD_SLIP_PENDING
    FROM OT_PWO_HEAD,
    OM_ITEM,
    OT_PWO_STAGE_DETAIL,
    OT_PWO_FG_PACKED_ITEM
    WHERE PWH_ITEM_CODE = ITEM_CODE
    AND PWFGPI_PWH_SYS_ID = PWH_SYS_ID
    AND NVL(PWH_CLO_STATUS,0) = 0
    AND PSD_PWH_SYS_ID = PWH_SYS_ID
    AND PWH_PS_QTY_BU / 1000 IS NULL
    GROUP BY PWH_NO,
    PWH_DT,
    PWH_ITEM_CODE,
    ITEM_NAME,
    PWFGPI_ITEM_CODE,
    PWFGPI_QTY,
    PSD_PR_ACCP_QTY_BU,
    PWH_PS_QTY_BU,
    ITEM_CODE
    ORDER BY PWH_NO

    That's a big query.
    Can I point out that
                    (CASE
                        WHEN SUM (  TO_NUMBER (soi_qty || '.' || soi_qty_ls)
                                  - (  soi_invi_qty_bu
                                     / iu_conv_factor
                                     / iu_max_loose_1
                                 ) < 0
                           THEN 0
                        ELSE SUM (  TO_NUMBER (soi_qty || '.' || soi_qty_ls)
                                  - (  soi_invi_qty_bu
                                     / iu_conv_factor
                                     / iu_max_loose_1
                     ENDis just
                    GREATEST(0, SUM (  TO_NUMBER (soi_qty || '.' || soi_qty_ls)
                                  - (  soi_invi_qty_bu
                                     / iu_conv_factor
                                     / iu_max_loose_1
                                    )and
                    DECODE (item_rord_qty_ls,
                            NULL, item_rord_qty,
                            (item_rord_qty || '.' || item_rord_qty_ls
                           )is just
    RTRIM (item_rord_qty || '.' || item_rord_qty_ls,'.')

  • How to correctly perform a join to get the desired output

    Hi,
    I have the following query which gives me the desired output.
    SELECT
    Cast(TEDW_F_STORE_OPS_GOAL.LOCATION_NUM As Varchar) As LOCATION_NUM,
    Cast(TEDW_D_DATE_TYPE_1.DATE_SHORT As Varchar) As DATE_SHORT,
    'Store' As DRIVER_TYPE,
    'OPS GOAL' As DRIVER,
    SUM(OPS_GOAL) As ROW_TOTAL
    FROM Planning.TEDW_F_STORE_OPS_GOAL
    left outer join
    edw.Calendar.TEDW_D_DATE_TYPE_1
    ON TEDW_F_STORE_OPS_GOAL.DATE_KEY = TEDW_D_DATE_TYPE_1.DATE_KEY
    left outer join
    [EDW].[Location].[TEDW_D_LOCATION_TYPE_1_NEW]
    ON TEDW_F_STORE_OPS_GOAL.LOCATION_NUM = TEDW_D_LOCATION_TYPE_1_NEW.LOCATION_NUM
    where TEDW_D_LOCATION_TYPE_1_NEW.LOCATION_TYPE_DESC = 'FULL PRICE STORE'
    group by
    TEDW_F_STORE_OPS_GOAL.LOCATION_NUM,
    TEDW_D_DATE_TYPE_1.DATE_SHORT
    order by LOCATION_NUM desc
    , DATE_SHORT desc
    The output of the above query will be like this
    3646 2014-04-17 Store OPS GOAL 2598.00000
    3646 2014-04-16 Store OPS GOAL 2475.00000
    3646 2014-04-15 Store OPS GOAL 2497.00000
    3646 2014-04-14 Store OPS GOAL 2691.00000
    But the problem with this query is it brings back the OPS Goal for all the dates,but i have to limit the OPS goals to some particular date range which must match to this table Staging.TEDW_S_EMPOWER.So,I made the above query join to this table like this
    SELECT
    Cast(TEDW_F_STORE_OPS_GOAL.LOCATION_NUM As Varchar) As LOCATION_NUM,
    Cast(TEDW_D_DATE_TYPE_1.DATE_SHORT As Varchar) As DATE_SHORT,
    'Store' As DRIVER_TYPE,
    'OPS GOAL' As DRIVER,
    SUM(OPS_GOAL) As ROW_TOTAL
    FROM Planning.TEDW_F_STORE_OPS_GOAL
    left outer join
    edw.Calendar.TEDW_D_DATE_TYPE_1
    ON TEDW_F_STORE_OPS_GOAL.DATE_KEY = TEDW_D_DATE_TYPE_1.DATE_KEY
    left outer join
    [EDW].[Location].[TEDW_D_LOCATION_TYPE_1_NEW]
    ON TEDW_F_STORE_OPS_GOAL.LOCATION_NUM = TEDW_D_LOCATION_TYPE_1_NEW.LOCATION_NUM
    left outer join
    Staging.TEDW_S_EMPOWER
    on TEDW_D_DATE_TYPE_1.DATE_SHORT = TEDW_S_EMPOWER.DATE_SHORT
    and TEDW_F_STORE_OPS_GOAL.LOCATION_NUM = TEDW_S_EMPOWER.LOCATION_NUM
    where TEDW_D_LOCATION_TYPE_1_NEW.LOCATION_TYPE_DESC = 'FULL PRICE STORE'
    group by
    TEDW_F_STORE_OPS_GOAL.LOCATION_NUM,
    TEDW_D_DATE_TYPE_1.DATE_SHORT
    having TEDW_D_DATE_TYPE_1.DATE_SHORT between MIN(TEDW_S_EMPOWER.date_short) and MAX(TEDW_S_EMPOWER.date_short)
    order by LOCATION_NUM desc
    , DATE_SHORT desc
    Now the output of this query will be like this
    3646 2014-04-17 Store OPS GOAL 7794.00000
    3646 2014-04-16 Store OPS GOAL 7425.00000
    3646 2014-04-15 Store OPS GOAL 7491.00000
    3646 2014-04-14 Store OPS GOAL 8073.00000
    If you can observe the OPS Goal Sum values have changed drastically, i was able to limit the date range i wanted but now i dont get the correct OPS Goal values.
    Can someone please help me with this?
    Thanks

    Hi RJP,
    Yes you are absolutely correct, in the "Staging.TEDW_S_EMPOWER"
    we have 3 rows for every date and location,so i changed my second sql to be something like this
    SELECT
    Cast(TEDW_F_STORE_OPS_GOAL.LOCATION_NUM As Varchar) As LOCATION_NUM,
    Cast(TEDW_D_DATE_TYPE_1.DATE_SHORT As Varchar) As DATE_SHORT,
    'Store' As DRIVER_TYPE,
    'OPS GOAL' As DRIVER,
    SUM(OPS_GOAL) /3 As ROW_TOTAL
    FROM Planning.TEDW_F_STORE_OPS_GOAL
    cross join
    EDW.Utility.TEDW_J_PROCESS_DATE
    inner join
    edw.Calendar.TEDW_D_DATE_TYPE_1
    ON TEDW_F_STORE_OPS_GOAL.DATE_KEY = TEDW_D_DATE_TYPE_1.DATE_KEY
    left outer join
    [EDW].[Location].[TEDW_D_LOCATION_TYPE_1_NEW]
    ON TEDW_F_STORE_OPS_GOAL.LOCATION_NUM = TEDW_D_LOCATION_TYPE_1_NEW.LOCATION_NUM
    left outer join
    Staging.TEDW_S_EMPOWER
    on TEDW_D_DATE_TYPE_1.DATE_SHORT = TEDW_S_EMPOWER.DATE_SHORT
    and TEDW_F_STORE_OPS_GOAL.LOCATION_NUM = TEDW_S_EMPOWER.LOCATION_NUM
    where TEDW_D_LOCATION_TYPE_1_NEW.LOCATION_TYPE_DESC = 'FULL PRICE STORE'
    group by
    TEDW_F_STORE_OPS_GOAL.LOCATION_NUM,
    TEDW_D_DATE_TYPE_1.DATE_SHORT
    having TEDW_D_DATE_TYPE_1.DATE_SHORT between MIN(TEDW_S_EMPOWER.date_short) and MAX(TEDW_S_EMPOWER.date_short)
    order by LOCATION_NUM desc
    , DATE_SHORT desc
    Now i receive the correct values as i am doing divided
    by 3,but may be in the future the empower tablemay have more than 3 ,is there any other effective way i can do this?
    below is the sample query and sample data from empower table.
    select * from Staging.TEDW_S_EMPOWER
    where DATE_SHORT = '2014-04-17'
    and LOCATION_NUM = 3020
    DRIVER_TYPE DRIVER DATE_SHORT
    store Sales 2014-04-17
    store Transactions 2014-04-17
    store Traffic 2014-04-17
    Thanks

  • I am needing 3 output displays on my mini.

    We are needing 3 outputs but the thunderbolt only allows 2 outputs. Can I use the USB output as my 3rd display with an adapter?

    Yes, there are USB video adopters like
    http://www.tripplite.com/usb-3.0-superspeed-to-displayport-dual-monitor-external -video-graphics-card%20adapter-512-mb-sd…
    However, there may be some lag.
    there is also this
    http://www.matrox.com/graphics/en/products/gxm/dh2go/digital_me/

Maybe you are looking for