Using - Partition By in SQL report

Our users are having problem with the below formula on Reports. I am not sure what this means. Our Users told that they need
(Tons Used/spread miles) * 2000 lb/ton = lbs/spread mile for their report.
And I see the below formula being used by our developer. Not sure how to read it though. Can any one let me know the formula used in the below code could actually represent the above formula. Users are complainting as below
from user ->column doubles or triples the amount if there are multiple records for the same truck/driver/beat/with the same amount for Dry Mat used and Spread Miles. If spread miles or the Dry Mat used is different if calculates correctly.
Edited by: Lucy Discover on Mar 28, 2011 1:50 PM

Hi,
Lucy Discover wrote:
Our users are having problem with the below formula on Reports. I am not sure what this means. Our Users told that they need
(Tons Used/spread miles) * 2000 lb/ton = lbs/spread mile for their report.
And I see the below formula being used by our developer. Not sure how to read it though. Can any one let me know the formula used in the below code could actually represent the above formula. Users are complainting as below
from user ->column doubles or triples the amount if there are multiple records for the same truck/driver/beat/with the same amount for Dry Mat used and Spread Miles. If spread miles or the Dry Mat used is different if calculates correctly.
SUM (ROUND ((NVL (sim_trip.dry_mat_used, 0)) /
nullif(sim_trip.spread_miles_total,0) * 2000, 2 ))
OVER (PARTITION BY sim_trip.trip_no,   sim_trip.dry_mat_code,        sim_trip.liquid_mat_code,
sim_trip.dry_mat_used,      sim_trip.liq_mat_used,         sim_trip.spread_miles_total
Yes, the code is basically implementing that formula. There's some code that hadles NULLs and rounds the amounts.
This is the analytic SUM function; the keyword OVER right after the argument indicates that. The difference (here) between the two forms is that the analytic SUM will work without a GROUP BY clause; you can show details about individual rows and the groupd total on the same output row, without doing a sub-query and a join. The analytic PARTITION BY clause correspdons to the aggregate GEOUP BY clause. Since you are saying:
...   OVER ( PARTITION BY  sim_trip.trip_no
                ,                 sim_trip.dry_mat_code
          ,                sim_trip.liquid_mat_code
          ,             sim_trip.dry_mat_used
          ,              sim_trip.liq_mat_used
          ,                 sim_trip.spread_miles_total
             )the ratio on any given row will only include rows with the same values of all 6 variables. It's very suspicious that two of those varibales (dry_mat_used and spread_miles_total) are also in the argument. That's legal, but it's very unusual.
Also, this is a sum or ratios, no a ratio of sums. That is, suppose, in some group, there are 2 rows. One row has 100 tons and 4 miles, while the other row has 100 tons and 1 mile. The formula you posted would repoert that as
(100 / 4) + ( 100 / 1) =
(25) + (100) =
125
and not
(100 + 100) / (4 + 1) =
(200) / (5) =
40
As you can see, there's a big difference. I don't know which one you want.
Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables.
Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
Always say which version of Oracle you're using.

Similar Messages

  • Use javascript value in SQL report

    Hello,
    I'm trying to do a report that must use the windows username as a filter. Something like
    select *
    from audit
    where username = WINDOWS_USERNAME.
    I have this code that retrieves it from the system
    <script language="Javascript">
    var WshNetwork = new ActiveXObject("WScript.Network");
    var userName;
    function getUsername(){
    userName = WshNetwork.UserName;
    return userName;
    Does anyone know how can I use it?
    Another possibility is having a application item that is populated in the onLoad event. Help please!

    I'm going to show you how I implemented my solution:
    I have in the login page a html region with the following code:
    <script language="Javascript">
    var WshNetwork = new ActiveXObject("WScript.Network");
    html_GetElement('P111_USERNAME').value = WshNetwork.UserName;
    document.write('<b>'+html_GetElement('P111_USERNAME').value+'</b>
    </script>When the user clicks the button I have a computation that sets a application item with the value of the P111_USERNAME hidden field.
    In all the others pages I reference the application item and it has the correct value.
    Your errors should be because you are declaring the ActiveX object outside the function. Or it's just a security limitation of your IE.
    Message was edited by:
    Reise

  • Pl-sql report with parameter

    Hi
    I have created report with region source as pl-sql. In pl-sql block, calling package where i am passing query. In query's where clause i want to pass paramter value which user had selected.
    There are two regions on page. On upper part, there is select list, on lower part there is report with pl-sql region but value of select list is not found in query. I am trying to access with bind variable, select list of item :SL_TEXT. But it is not showing any value in it.
    How to use select list value in query of report? Or let me know how to use parameter in pl-sql report which is selected in other region?
    Thanks in advance

    I am attempting to define the variable as a date variable through Oracle BI and yes it does use a colon to signal variable substitution.
    So thank you the first way you stated should work.
    The only problem I'm running into now I believe steems from the date format that column that I am trying to filter on. It is in what appears to be the worst format possible.
    Is it common for dates to be stored in a DD-MON-YY format? (e.g. 01-JAN-08) I thought we as a community had moved past that post Y2K scare. lol.
    When I set up the bind variable in BI it allows me to define the date format, much similar to the TO_DATE function but then it says (must be java date format). So I'm thinking that maybe DD-MON-YY is not a java date format.
    In that case is there a way to cast or convert my date format in the sql so that it is a supported java date format?
    Or should I just give up and pass it as a varchar2?

  • Break line in SQL report

    Hi,
    I am using APEX 4.0 ver .I have created SQL report with 1 column and its looks good but problem is, This columns has huge amount of data for example 1000 words and in the report it is displaying like *****************************************************************
    so, i dont want to display continous words and i want to display the data like ********************
    How could i break the contonous line and display the same in multiple lines.
    thanks in advance.
    Regards
    Narender B

    Hi Aditya,
    Am using following query in sql report
    SELECT message ||' Updated BY ' || user_name || ' On ' || to_char (last_update_date,'MM/DD/YY') message
    FROM TEST .
    This message column has huge data with spaces like *abcd xxxxx yyxs xxxxxx ttttttt abchd ddfjkllglrhr[kng;lrthrthkmrp gkjoph fegjhgignrtmblk*  and this huge data not able to fit in the screen so, we need to create multiple lines to fit in the screen.
    How can i create multiple lines in report.
    Thanks
    Narender B                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Convert SQL*Report Writer V1 to Reports V6

    Is there an Oracle utility to convert the old SQL*Report Writer REPs to Reports V6 RDFs? Also, will Reports V6 for Unix be able to use our REPs from SQL*Report Writer V1?
    We are moving to a new server and updating our Oracle software. As a test, we are attempting to rewrite / convert some of our reports from our Unix platform to a test NT server. Once we get to the new Unix server and Oracle, we will have to convert the old REPs to the new Reports for Unix.

    You can convert SQL*ReportWriter v1.1 reports to Oracle Reports 2.5/3.0 and then to Oracle Reports 6.0. I know there is a migration tool that comes with 2.5, though I'm not sure about 3.0.

  • SQL report region source to call a pl/sql function using DB link

    Hi - I have a pl/sql function fn_dbtype(id NUMBER) defined in database X. The pl/sql function executes couple DML statements and returns a string (a SELECT query). I am able to call this function using SQL Plus (Connected to Database X) as below and it works fine:
    declare
    vSQL VARCHAR2(100);
    begin
    vSQL := fn_dbtype(1);
    end;
    The DML operations completed fine and vSQL contains the "Select" query now.
    In APEX:
    I am trying to create a SQL report in APEX using SQL query(PL/SQL function returning a sql statement) option. I am trying to figure out what to put in the region source so that the output of the "Select" query is displayed in the report.
    Moreover APEX is hosted in a different database instance. So I would need to call this pl/sql function using a DB Link.
    Please let me know what I need to put in the region source to execute the pl/sql function which returns the "Select" query thereby displaying the query output in the report. Thanks.
    Edited by: user709584 on Mar 19, 2009 2:32 PM
    Edited by: user709584 on Mar 19, 2009 2:34 PM

    try something like this:
    return fn_dbtype(1)@dblink;

  • Simple PL/SQL Report - Using Break on and Compute Sum - Not So Simple

    Good morning, All:
    I have a simple pl/sql report that is not so simple. Basic on the code below, would like to add a blank line/row after the resulting "sum" row to make it easier to read. Any and all help would be appreciated.
    Thank you.
    Preston@Large
    Code:
    =======================
    BREAK ON ALM_OG_CAMPAIGN_CODE
    COMPUTE SUM OF ALM_OG_AMOUNT ON ALM_OG_CAMPAIGN_CODE
    set linesize 1024
    set pagesize 60
    set newpage 0
    set serveroutput on
    SPOOL &so_outfile;
    ttitle center 'Wayne State University' skip 1 Left 'WSU Online Giving Essentials Report' skip 2
    select TO_CHAR(sysdate, 'mm/dd/yyyy hh:mm AM') "Report Date" from dual;
    CLEAR COLUMNS
    column ALM_OG_ACCI_CODE heading "ACCI|CODE" format a10
    column ALM_OG_AMOUNT heading "AMOUNT|DONATED" format $999,999,999.99
    column ALM_OG_CAMPAIGN_CODE heading "CAMPAIGN|CODE" format a14
    select
    ALM_OG_CAMPAIGN_CODE,
    ALM_OG_ACCI_CODE,
    ALM_OG_AMOUNT
    From WSUALUMNI.WSU_ONLINE_GIVING_TABLE
    ORDER BY ALM_OG_CAMPAIGN_CODE;
    CLEAR COLUMNS
    spool off
    Output:
    WSU Online Giving Essentials Report
    Report Date
    ======================
    06/05/2009 10:06 AM
    1 row selected.
    Wayne State University
    WSU Online Giving Essentials Report
    CAMPAIGN ACCI AMOUNT
    CODE CODE DONATED
    ====== ======== ==========
    sum $560.00
    NUR 444814 $10.00
    ***** =======
    sum $10.00
    PHS 445216 $10.00
    ***** =======
    sum $10.00
    PRES 445211 $450.00
    445211 $60.00
    445211 $250.00
    ***** =======
    sum $760.00
    SBA 444216 $10.00
    ***** =======
    sum $10.00
    SSW 444469 $10.00
    ***** =======
    sum $10.00

    Prestone,
    Welcome to the Forum!
    I have used skip 2 lines you can use 1
    SQL> break on job report skip 2
    SQL> compute sum of sal on job report
    SQL> select job , sal from emp order by job ;
    JOB              SAL
    ANALYST         3000
                    3000
    sum             6000
    CLERK           1300
                     950
                     800
                    1100
    sum             4150
    MANAGER         2850
                    2975
                    2450
    sum             8275
    PRESIDENT       5000
    sum             5000
    SALESMAN        1500
                    1250
                    1250
                    1600
    sum             5600
    14 rows selected.READ
    Quick SQL*Plus Guide
    http://download.oracle.com/docs/cd/B14117_01/server.101/b12171/toc.htm
    SQL*Plus Reference
    http://download.oracle.com/docs/cd/B14117_01/server.101/b12170/toc.htm
    SS

  • Report template 101 - Comment Bubbles (used during creating SQL Report)

    Hi,
    There is a Report template type - Comment Bubbles [ Theme - 24, 25, 26 ]
    Has anyone ever tried using this template while creating SQL Report.
    OR if anyone knows how to use this and what should be the syntax of SQL query for using this template.
    Thanks,
    Deepak

    Hi Deepak.
    I assume you're running APEX 4.2
    There is a packaged application included with 4.2 which is called "Customer Tracker"
    On page 50 you find a rewgion where these comment bubles are used ( unlock the application to view the source ).
    Regards
    Bas

  • Can we use different Databases (Oracle & SQL Server) in one report?

    Post Author: venki5star
    CA Forum: .NET
    Hi there.
    Can we use different databases (Oracle & SQL Server) in a same report?
    If possible how?
    Another question,
    Can we change the Provider Name at runtime of the given report. If so the above question is useless...
    Thanks in Advance.

    I tried this using Oracle Provider for OLEDB (the one that supplied by Oracle Client) and Crystal Reports 9. you can drag the column into designer but the image does not appear in preview.
    I guess it's because CR does not recognized it as image, and there are no information that the blob data is an image at all.

  • BPC security can be used in SQL Reporting Services?

    Hello,
    We are trying to implement SQL Reporting Services(RS) as web reports of BPC.
    Is it possible to use BPC security user access control in SQL RS?
    We know that SQL RS user access can be managed by windows domain, but we like to use BPC security as SQL RS user control.
    Thank you in advance.
    Sam

    Hello,
    We are trying to implement SQL Reporting Services(RS) as web reports of BPC.
    Is it possible to use BPC security user access control in SQL RS?
    We know that SQL RS user access can be managed by windows domain, but we like to use BPC security as SQL RS user control.
    Thank you in advance.
    Sam
    ==================================================================
    Hi Sam,
    Could you be more specific on what you are going to do with RS?
    BPC, as you know, uses Windows AD. If you intend to use RS in BPC, you have already introduced Windows AD and BPC access security for RS.  But only given RS report is eligible in this case.
    If you want to make a report that refers to business data of BPC, and need to pass argument as query parameter such as what category, what entity, not possible actaully, no way to make it happen with standard feature of BPC. But you can think of possibility of customizing and need to find out how to pass the argument for a user(read ACS table containing security info).
    Reg. the reporting tool, if you are using 7.5, BO products is aligned well. Xcelsius and Voyager will be a tool for your requirement.
    Regards,
    YH Seo

  • Using Azure internal load balancer (ILB) for Sql Reporting Services

    I am attempting to implement a scale-out SSRS deployment using the Azure ILB feature. I have created 2 Sql Reporting servers using the azure images and have created a ILB endpoint on both servers.  I am then attempting to access the servers via the
    ILB from my .Net web application.  I can access the report server from my browser and am prompted for credentials using forms authentication.  there is no issue accessing the reports from a browser however my web application cannot access the reports
    and returns a 500 error.  I have a hunch this is due to an authentication issue due to invalid kerberos proxy authentication.
    Does anyone have any information regarding the possible authentication mechanisms that are supported using Azure ILB?  

    Thanks for the response Swallow0417, but as I stated I already had configured this to work in a browser.  I should have mentioned that I already had set the machine key and altered the rsreportserver.config file as mentioned in
    https://msdn.microsoft.com/en-us/library/cc281307.aspx.
    It turns out this was due to the extended data validation that was introduced in SQL 2014. 
    This page led me to alter rsreportserver.config so that:
    <RSWindowsExtendedProtectionLevel>Off</RSWindowsExtendedProtectionLevel>
    <RSWindowsExtendedProtectionScenario>Any</RSWindowsExtendedProtectionScenario>
    After restarting the report server service my application now can make the requests for the reports successfully.  I'll provide the other steps I took to hopefully help someone else in the future:
    1. Create 2 or more SQL servers in an Azure availability group on the same service in a Reports server scale out deployment.  The SSRS Service account must be a domain account or it will not work
    2. Create an Azure ILB using powershell and add the endpoints on your http(s) ports on the server in step 1. I also set the endpoint IdleTimeoutInMinutes to 30 on both endpoints as it seemed like there was some possible timeout issues. the endpoint MUST
    also have DirectServerReturn Set to $true 
    3. disable the loopbackcheck see method 2 here
    http://support.microsoft.com/kb/896861
    create a DWORD registry key value 1,
    DisableLoopbackCheck,
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
    4. Configure View state validation by setting an identical machine key on all servers behind the azure ILB
    5. Create a Host record in your AD DNS for the Azure ILB IP Address. 
    6. configure hostname
    and URLRoot in rsreportserver.config - see
    https://msdn.microsoft.com/en-us/library/cc281307.aspx
    Setting the hostname tag breaks the report manager url. It is only
    required to set the URLRoot tag. I do not think it is required in this configurtaion only for Windows
    NLB
    6. Configure the authentication method in rsreportserver.conig
      <RSWindowsExtendedProtectionLevel>Off</RSWindowsExtendedProtectionLevel>
      <RSWindowsExtendedProtectionScenario>Any</RSWindowsExtendedProtectionScenario>

  • Using Bind variables in SQL PLUS Report

    using Bind variables in SQL PLUS Report. This report gets the arguments from the application concurrent program. Now my need is to convert the start_date and end_date to bind Variables to improve the performance. I have commented the original code in 'prompt List of Unapproved Adjustments' and used my Bind Variable but it is giving an error
    error: Bind Variable "ENDING_DATE" not declared
    Report Date and Time:
    26-OCT-2010 15:44:13
    List of Unapproved Adjustments
    Bind Variable 'ENDING_DATE" not declared
    Please see below the code for the sql plus report:
    define p_org_id           = '&1'
    define p_fy_begin_date = '&2'
    define p_start_date = '&3'
    define p_end_date = '&4'
    define p_conversion = '&5'
    declare
    variable begin_date date;
    exec :begin_date := p_start_date;
    variable ending_date date;
    exec :ending_date := p_end_date;
    /* Begin
    :begin_date := to_date('&p_start_date','YYYY/MM/DD HH24:MI:SS');
    :ending_date := to_date('&p_end_date','YYYY/MM/DD HH24:MI:SS');
    End; */
    set newpage none
    set termout off
    set pagesize 55
    set linesize 180
    set heading on
    set feedback off
    set wrap off
    set space 1
    set heading on
    begin
    dbms_application_info.set_client_info('&p_org_id');
    end;
    prompt
    prompt Report Date and Time:
    prompt ----------------------
    select to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')
    from dual ;
    prompt
    prompt List of Unapproved Adjustments
    prompt -------------------------------
    select b.trx_number,
    a.adjustment_number,
    f.user_name created_by
    from apps.ar_adjustments a,
    apps.ra_customer_trx b,
    apps.fnd_user f
    where a.customer_trx_id = b.customer_trx_id
    and a.status <> 'A'
    and a.created_by = f.user_id
    and a.creation_date between :begin_date
    and :ending_date
    -- and a.creation_Date between to_date('&p_start_date','YYYY/MM/DD HH24:MI:SS')
    -- and to_date('&p_end_date','YYYY/MM/DD HH24:MI:SS')
    order by
    b.trx_number ;

    Hi
    Please go to customization part of the report and verify..You have set a default value out there ..And also verify your lov and look at the values ..If it is again giving you the problem ..pl delete the report and develop it again from the scratch it will be solved...
    vishnu
    null

  • How To Use a Hidden Page Item within an SQL Report Query without Submitting

    Hi,
    Using: Oracle ApEx 3.0.1
    I have an sql report region that contains a hidden page item as part of the "where clause". My problem is, based on a value entered by the user, I need to assign this value enetered to my hidden item, so that it can be used within the where condition of my sql but this would need to be done without actually submitting the form.
    At the moment, I can set the value via an on-demand process but my SQL is still not returing any values as the hidden page item within the query is not set (as page has not been submitted).
    Can anybody please assist as I am not sure how to do this and whether in actual fact, this is possible to do, without having submitted the page.
    Thanks.
    Tony.
    Edited by: Tony F. on Nov 12, 2011 1:39 AM

    You can set a session value using a dummy ajax call e.g:
    Add the following to the 'Function and Global Variable Declaration' region
    function f_set_item(pThis){
      var get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=dummy',1);
      get.add('P1_ID',pThis.value)
      gReturn = get.get();
      get = null;
    }Where P1_ID is the session value to be set. Then call the function in the usual way e.g.
    javascript:f_set_item(this);
    I hope that helps
    Shunt

  • Append Today Date to the Attachement Name using SQL reporting services

    I have a report on SQL reporting services, I have scheduled this report to be sent automatically by mail using Subscriptions but the client needs to append today date to the report name attached, currently the attachment is taking the report name as it is.
    EX: CollectExport.txt but what I need is to have CollectExport_21-07-2010.txt .
    Please advise.
    Thanks.

    As I understand it, the purpose of the program is to route a report file that contains the name of the report with the current date appended to the end. So, have you tried to use the ReportViewer control and extrude the report as a PDF stream (which you
    can name)?
    William Vaughn
    Mentor, Consultant, Trainer, MVP
    http://betav.com
    http://betav.com/blog/billva
    http://www.hitchhikerguides.net
    “Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)”
    Please click the Mark as Answer button if a post solves your problem!

  • How to update the sql report column create using Htmldb_item

    Hi,
    I have a updateable sql report,which consist of htmldb_item like
    htmldb_item.hidden(1,a.id) "ID",
    htmldb_item.display_and_save(2,a.question,2,100) "Question",
    htmldb_item.text(3,b.answer,20,1000) "Answer"
    now in the report 'answer' coloumn i have made updateable,but my question is how to create the valdiation on the answer coloumn of the report.
    As i been to page source and for all the record of the answer coloumn the array id is f03, so how to identify the particular 'answer' on the report and give the validation for them...
    Thanks

    Validations in Apex are designed to operate upon individual page items that you have defined on the page, not tabular form elements.
    Search the forum for other techniques you can use
    http://forums.oracle.com/forums/search.jspa?objID=f137&q=tabular+form+validate+declaratively+javascript

Maybe you are looking for