SQL Query with 3 tables to create a view

Hi
I have got an existing view "View_output" formed with a query which works fine:
select A,B,C,D,E,F,G,H from GTS1 where D is not null
    UNION
   select A,B,C,D,E,F,G,H from GTSN1 where D is not null;It works fine, in the output I have columns A,B,C,D,E,F,G,H
New requirement : Modify the view, by adding a new column 'I' so that the view should have
columns A through I, and no column values should be null.
This column "I" is coming from a table, say DLC
Data in DLC is a subset of the original view "View_output"and DLC have the foll.columns:
("View_output" is a datablock source for a form and only selected column values are put as output in DLC
after form manipulation)
DLC is having only 5 columns -B,C,F,H,I
When I give:
(select A,B,C,D,E,F,G,H,NULLfrom GTS1 where D is not null
    UNION
   select A,B,C,D,E,F,G,H,NULL from GTSN1 where D is not null)
UNION
select NULL,B,C,NULL,NULL,F,NULL,H,I
    from
    DLC where I IS NOT NULL;It UNIONS all required rows in the 3 tables but columns A,D,E,G are NULL, but how can I get
data in these columns?
Edited by: Krithi on 30-Oct-2009 05:43
Edited by: Krithi on 30-Oct-2009 08:13

Hi arun thats not the real isue..
I have corrected the second code now, it was a typo from my side..
all three tables already have 9 columns selected..
The view created from GTS1 and GTSN1 is constantly changing
There is no way to add column 'I' to any of these above tables
The view is the input to a form..User ticks a tickbox corresponding to records needed by them (These are the columns in the original view mentioned above)..and based on certain logic,only selected columns are now inserted/updated into the output table through the form..this is the table DLC
Now they want to insert a new data(free text) through the form, this field correspond to each record in the form ;this is supposed to be column 'I'(not designed yet)..
this is not there in the original input tables selected for the view...But then I added this column to the output table DLC (Cant think of any other method) so that column I can also get combined in the view.
Now what I want is recreate the view through,
create or replace view statement.
the view should effectively pull data from 3 tables .
The relation between 3 tables :
DLC is a subset of GTS1 and GTSN1
but may also contain data which is not in union of GTS1 and GTSN1
Only field I need from DLC is field 'I', and that too if the data is there in the union of GTS1 and GTSN1

Similar Messages

  • How can I create a query with tables in INFOSET?

    Dear Gurus,
    How can I create a query with tables in INFOSET?
    Just tables and fields INFOSET?
    Kind Regards,

    Hello
    Check following SCN Article for your understanding/reference:
    - [Using Infoset Query ,SAP Query and Quick Viewer|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/10eab7af-0e54-2c10-28a5-87b47adbe1a5]
    Regards
    JP

  • Need help with SQL Query with Inline View + Group by

    Hello Gurus,
    I would really appreciate your time and effort regarding this query. I have the following data set.
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
    1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
    Please Ignore '----', added it for clarity
    I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number. When there are no multiple records I want to display the respective Description.
    The query should return the following data set
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
    The following is my query. I am kind of lost.
    select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    from (
    select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
    from INVOICE
    group by sequence_id,check_date, check_number, invoice_number, vendor_number
    ) A, INVOICE B
    where A.sequence_id = B.sequence_id
    Thanks,
    Nick

    It looks like it is a duplicate thread - correct me if i'm wrong in this case ->
    Need help with SQL Query with Inline View + Group by
    Regards.
    Satyaki De.

  • SQL query with Bind variable with slower execution plan

    I have a 'normal' sql select-insert statement (not using bind variable) and it yields the following execution plan:-
    Execution Plan
    0 INSERT STATEMENT Optimizer=CHOOSE (Cost=7 Card=1 Bytes=148)
    1 0 HASH JOIN (Cost=7 Card=1 Bytes=148)
    2 1 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=4 Card=1 Bytes=100)
    3 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=3 Card=1)
    4 1 INDEX (FAST FULL SCAN) OF 'TABLEB_IDX_003' (NON-UNIQUE)
    (Cost=2 Card=135 Bytes=6480)
    Statistics
    0 recursive calls
    18 db block gets
    15558 consistent gets
    47 physical reads
    9896 redo size
    423 bytes sent via SQL*Net to client
    1095 bytes received via SQL*Net from client
    3 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    55 rows processed
    I have the same query but instead running using bind variable (I test it with both oracle form and SQL*plus), it takes considerably longer with a different execution plan:-
    Execution Plan
    0 INSERT STATEMENT Optimizer=CHOOSE (Cost=407 Card=1 Bytes=148)
    1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=3 Card=1 Bytes=100)
    2 1 NESTED LOOPS (Cost=407 Card=1 Bytes=148)
    3 2 INDEX (FAST FULL SCAN) OF TABLEB_IDX_003' (NON-UNIQUE) (Cost=2 Card=135 Bytes=6480)
    4 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=2 Card=1)
    Statistics
    0 recursive calls
    12 db block gets
    3003199 consistent gets
    54 physical reads
    9448 redo size
    423 bytes sent via SQL*Net to client
    1258 bytes received via SQL*Net from client
    3 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    55 rows processed
    TABLEA has around 3million record while TABLEB has 300 records. Is there anyway I can improve the speed of the sql query with bind variable? I have DBA Access to the database
    Regards
    Ivan

    Many thanks for your reply.
    I have run the statistic already for the both tableA and tableB as well all the indexes associated with both table (using dbms_stats, I am on 9i db ) but not the indexed columns.
    for table I use:-
    begin
    dbms_stats.gather_table_stats(ownname=> 'IVAN', tabname=> 'TABLEA', partname=> NULL);
    end;
    for index I use:-
    begin
    dbms_stats.gather_index_stats(ownname=> 'IVAN', indname=> 'TABLEB_IDX_003', partname=> NULL);
    end;
    Is it possible to show me a sample of how to collect statisc for INDEX columns stats?
    regards
    Ivan

  • How could I replace hard coded value in my sql query with constant value?

    Hi all,
    Could anyone help me how to replace hardcoded value in my sql query with constant value that might be pre defined .
    PROCEDURE class_by_day_get_bin_data
         in_report_parameter_id   IN   NUMBER,
         in_site_id               IN   NUMBER,
         in_start_date_time       IN   TIMESTAMP,
         in_end_date_time         IN   TIMESTAMP,
         in_report_level_min      IN   NUMBER,
         in_report_level_max      IN   NUMBER
    IS
      bin_period_length   NUMBER(6,0); 
    BEGIN
      SELECT MAX(period_length)
         INTO bin_period_length
        FROM bin_data
         JOIN site_to_data_source_lane_v
           ON bin_data.data_source_id = site_to_data_source_lane_v.data_source_id
         JOIN bin_types
           ON bin_types.bin_type = bin_data.bin_type 
       WHERE site_to_data_source_lane_v.site_id = in_site_id
         AND bin_data.start_date_time     >= in_start_date_time - numtodsinterval(1, 'DAY')
         AND bin_data.start_date_time     <  in_end_date_time   + numtodsinterval(1, 'DAY')
         AND bin_data.bin_type            =  2
         AND bin_data.period_length       <= 60;
      --Clear the edr_class_by_day_bin_data temporary table and populate it with the data for the requested
      --report.
      DELETE FROM edr_class_by_day_bin_data;
       SELECT site_to_data_source_lane_v.site_id,
             site_to_data_source_lane_v.site_lane_id,
             site_to_data_source_lane_v.site_direction_id,
             site_to_data_source_lane_v.site_direction_name,
             bin_data_set.start_date_time,
             bin_data_set.end_date_time,
             bin_data_value.bin_id,
             bin_data_value.bin_value
        FROM bin_data
        JOIN bin_data_set
          ON bin_data.bin_serial = bin_data_set.bin_serial
        JOIN bin_data_value
          ON bin_data_set.bin_data_set_serial = bin_data_value.bin_data_set_serial
        JOIN site_to_data_source_lane_v
             ON bin_data.data_source_id = site_to_data_source_lane_v.data_source_id
            AND bin_data_set.lane = site_to_data_source_lane_v.data_source_lane_id
        JOIN (
               SELECT CAST(report_parameter_value AS NUMBER) lane_id
                 FROM report_parameters
                WHERE report_parameters.report_parameter_id    = in_report_parameter_id
                  AND report_parameters.report_parameter_group = 'LANE'
                  AND report_parameters.report_parameter_name  = 'LANE'
             ) report_lanes
          ON site_to_data_source_lane_v.site_lane_id = report_lanes.lane_id
        JOIN (
               SELECT CAST(report_parameter_value AS NUMBER) class_id
                 FROM report_parameters
                WHERE report_parameters.report_parameter_id    = in_report_parameter_id
                  AND report_parameters.report_parameter_group = 'CLASS'
                  AND report_parameters.report_parameter_name  = 'CLASS'
             ) report_classes
          ON bin_data_value.bin_id = report_classes.class_id
        JOIN edr_rpt_tmp_inclusion_table
          ON TRUNC(bin_data_set.start_date_time) = TRUNC(edr_rpt_tmp_inclusion_table.date_time)
       WHERE site_to_data_source_lane_v.site_id = in_site_id
         AND bin_data.start_date_time     >= in_start_date_time - numtodsinterval(1, 'DAY')
         AND bin_data.start_date_time     <  in_end_date_time   + numtodsinterval(1, 'DAY')
         AND bin_data_set.start_date_time >= in_start_date_time
         AND bin_data_set.start_date_time <  in_end_date_time
         AND bin_data.bin_type            =  2
         AND bin_data.period_length       =  bin_period_length;
    END class_by_day_get_bin_data;In the above code I'm using the hard coded value 2 for bin type
    bin_data.bin_type            =  2But I dont want any hard coded number or string in the query.
    How could I replace it?
    I defined conatant value like below inside my package body where the actual procedure comes.But I'm not sure whether I have to declare it inside package body or inside the procedure.
    bin_type     CONSTANT NUMBER := 2;But it does't look for this value. So I'm not able to get desired value for the report .
    Thanks.
    Edited by: user10641405 on May 29, 2009 1:38 PM

    Declare the constant inside the procedure.
    PROCEDURE class_by_day_get_bin_data(in_report_parameter_id IN NUMBER,
                                        in_site_id             IN NUMBER,
                                        in_start_date_time     IN TIMESTAMP,
                                        in_end_date_time       IN TIMESTAMP,
                                        in_report_level_min    IN NUMBER,
                                        in_report_level_max    IN NUMBER) IS
      bin_period_length NUMBER(6, 0);
      v_bin_type     CONSTANT NUMBER := 2;
    BEGIN
      SELECT MAX(period_length)
        INTO bin_period_length
        FROM bin_data
        JOIN site_to_data_source_lane_v ON bin_data.data_source_id =
                                           site_to_data_source_lane_v.data_source_id
        JOIN bin_types ON bin_types.bin_type = bin_data.bin_type
       WHERE site_to_data_source_lane_v.site_id = in_site_id
         AND bin_data.start_date_time >=
             in_start_date_time - numtodsinterval(1, 'DAY')
         AND bin_data.start_date_time <
             in_end_date_time + numtodsinterval(1, 'DAY')
         AND bin_data.bin_type = v_bin_type
         AND bin_data.period_length <= 60;
      --Clear the edr_class_by_day_bin_data temporary table and populate it with the data for the requested
      --report.
      DELETE FROM edr_class_by_day_bin_data;
      INSERT INTO edr_class_by_day_bin_data
        (site_id,
         site_lane_id,
         site_direction_id,
         site_direction_name,
         bin_start_date_time,
         bin_end_date_time,
         bin_id,
         bin_value)
        SELECT site_to_data_source_lane_v.site_id,
               site_to_data_source_lane_v.site_lane_id,
               site_to_data_source_lane_v.site_direction_id,
               site_to_data_source_lane_v.site_direction_name,
               bin_data_set.start_date_time,
               bin_data_set.end_date_time,
               bin_data_value.bin_id,
               bin_data_value.bin_value
          FROM bin_data
          JOIN bin_data_set ON bin_data.bin_serial = bin_data_set.bin_serial
          JOIN bin_data_value ON bin_data_set.bin_data_set_serial =
                                 bin_data_value.bin_data_set_serial
          JOIN site_to_data_source_lane_v ON bin_data.data_source_id =
                                             site_to_data_source_lane_v.data_source_id
                                         AND bin_data_set.lane =
                                             site_to_data_source_lane_v.data_source_lane_id
          JOIN (SELECT CAST(report_parameter_value AS NUMBER) lane_id
                  FROM report_parameters
                 WHERE report_parameters.report_parameter_id =
                       in_report_parameter_id
                   AND report_parameters.report_parameter_group = 'LANE'
                   AND report_parameters.report_parameter_name = 'LANE') report_lanes ON site_to_data_source_lane_v.site_lane_id =
                                                                                         report_lanes.lane_id
          JOIN (SELECT CAST(report_parameter_value AS NUMBER) class_id
                  FROM report_parameters
                 WHERE report_parameters.report_parameter_id =
                       in_report_parameter_id
                   AND report_parameters.report_parameter_group = 'CLASS'
                   AND report_parameters.report_parameter_name = 'CLASS') report_classes ON bin_data_value.bin_id =
                                                                                            report_classes.class_id
          JOIN edr_rpt_tmp_inclusion_table ON TRUNC(bin_data_set.start_date_time) =
                                              TRUNC(edr_rpt_tmp_inclusion_table.date_time)
         WHERE site_to_data_source_lane_v.site_id = in_site_id
           AND bin_data.start_date_time >=
               in_start_date_time - numtodsinterval(1, 'DAY')
           AND bin_data.start_date_time <
               in_end_date_time + numtodsinterval(1, 'DAY')
           AND bin_data_set.start_date_time >= in_start_date_time
           AND bin_data_set.start_date_time < in_end_date_time
           AND bin_data.bin_type = v_bin_type
           AND bin_data.period_length = bin_period_length;
    END class_by_day_get_bin_data;

  • How to write sql query with many parameter in ireport

    hai,
    i'm a new user in ireport.how to write sql query with many parameters in ireport's report query?i already know to create a parameter like(select * from payment where entity=$P{entity}.
    but i don't know to create query if more than 1 parameter.i also have parameter such as
    $P{entity},$P{id},$P{ic}.please help me for this.
    thanks

    You are in the wrong place. The ireport support forum may be found here
    http://www.jasperforge.org/index.php?option=com_joomlaboard&Itemid=215&func=showcat&catid=9

  • Extract Sql Query with Actual Parameters from Report

    Hi
    I am able to extract query from Crystal Report using the following code :
    ReportDocument.ReportClientDocument.RowSetController.GetSqlStatement(new GroupPath, out tmp);
    But the sql query retrieve comes in the following format :
    select name , trans_code, account_code from command_query.accounts
    where account_code = {?Command_query_Prompt0}  and effective_date < '{?Command_query_prompt1 }'
    The parameters which I m using in the reports are :
    Account_Code and Effective_Date .
    Why does my extracted sql translates it into {?Command_query_Prompt0} and '{?Command_query_prompt1 }' .
    Is there any way to map this to the actual parameter values ?
    OR
    Can we extract the query after assigning the values ?
    Any help is appreciated ... 
    Thanks
    Sanchet

    hi,
    You can create nested sql query with conditional parameters,
    For example
    Select Code From OITT Where Code IN (Select ItemCode From OITM
    Where ItemName LIKE '[%0]' + '%%')
    Edited by: Jeyakanthan A on Jun 9, 2009 12:31 PM

  • SQL query with JSP and WML-parameters

    Hey,
    Could you help me?
    I'm trying to do the following. WML deck card 1 send parameter to same WML deck's card help. I try to read the parameter with JSP in card help by putting the parameter to SQL query, but it doesn't work. I can read the parameter with WML in card help. I can also print the value of the parameter with JSP if I generate WML with JSP.
    /*parameter sending from card 1 to card help*/
    out.println("<go href='#helpcard'>");
    out.println("<setvar name='valittukurssi' value='$(valittukurssi)'/>");
    /*parameter read with WML in card help */
    <p>Valitse kurssi.
    $valittukurssi</p>
    /'parameter read with JSP by generating WML with JSP*/
    out.println("<p>$valittukurssi</p>");
    /* SQL query with JSP */
    ResultSet uudettulokset = uusilause.executeQuery("select * from kurssi where lyhenne='$valittukurssi'");
    Thanks,
    Rampe

    You're problem is easy to fix. You're confusing WML variables with JSP variables. See below:
    >
    /*parameter sending from card 1 to card help*/
    out.println("<go href='#helpcard'>");
    out.println("<setvar name='valittukurssi'
    value='$(valittukurssi)'/>");
    Above you set a var that will work on the phone, not in JSP.
    /*parameter read with WML in card help */
    <p>Valitse kurssi.
    $valittukurssi</p>
    Yes the above does display the parameter, because it is a client side WML var, but you cannot use this variable in the JSP code (that's why your SWL fails).
    /'parameter read with JSP by generating WML with
    JSP*/
    out.println("<p>$valittukurssi</p>");Here's you're problem, the above line is EXACTLY the same as the one before it. When the container parses through this JSP code it translates the above line to:
    <p>$valittukurssi</p> on the WML page and the CLIENT uses it's local variable to display it.
    What you need and want is to have a variable that can be used in JSP code and output to your WML page. Here's how it's done:
    out.println("<go href='#helpcard'>");
    String some_name = "valittukurssi";
    out.println("<setvar name='"+some_name+"'
    value='$("+some_name+")'/>");
    //note that you may have to escape the ( and ) with a \
    //so we displayed the variable above into the WML page, now we can use it in the SQL query:
    /* SQL query with JSP */
    ResultSet uudettulokset =
    uusilause.executeQuery("select * from kurssi where
    lyhenne='"+some_name+"'");//the end of the command is: " ' " ) ;
    Frank Krul
    Got Node?

  • How to compare result from sql query with data writen in html input tag?

    how to compare result
    from sql query with data
    writen in html input tag?
    I need to compare
    user and password in html form
    with all user and password in database
    how to do this?
    or put the resulr from sql query
    in array
    please help me?

    Hi dejani
    first get the user name and password enter by the user
    using
    String sUsername=request.getParameter("name of the textfield");
    String sPassword=request.getParameter("name of the textfield");
    after executeQuery() statement
    int exist=0;
    while(rs.next())
    String sUserId= rs.getString("username");
    String sPass_wd= rs.getString("password");
    if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
    exist=1;
    if(exist==1)
    out.println("user exist");
    else
    out.println("not exist");

  • Hosting company does not support SQL query with OUTFILE clause

    From my mysql database, I want to allow the user to run a query and produce a csv / text file of our membership database.   Unfortunately,  I just found out my hosting company does not support the SQL query with OUTFILE clause for MySQL database.
    Are there any other options available to produce a file besides me running the query in phpadmin and making the file available to users.
    Thanks.  George

    Maybe this external Export Mysql data to CSV - PHP tutorial will be of help
    Cheers,
    Günter

  • Problem creating an sql query with a parameter which is a list

    Hi,
    Im having a problem creating a certain SQL query.
    The query looks like this:
    SELECT gstock_id FROM germplasm_stock gps, germplasm gp WHERE gps.germplasm_id = gp.germplasm_id AND organism_id IN ($childList:VARCHAR).
    the organism_id field is of DECIMAL type.
    the parameter childList is actually a list of Id's, something like: 123,124,789
    and it is created dynamically by an other function, so I cant just put it there staticlly.
    I tried using the ARRAY type instead of VARCHAR, but that didn't work,
    anyone knows how can I give this query a parameter which is a list of numbers ?
    Thanks

    I have tried all the following options and the same issue occurs:
    EXEC dbo.uspGetSiteChanges @ChangeVersion = ?
    With Parameter: 0, @ChangeVersion, ChangeVersion
    EXEC dbo.uspGetSiteChanges ?
    With Parameter: 0, @ChangeVersion, ChangeVersion
    In my first data flow I use the following and it works on two OLE DB Sources:
    EXEC dbo.uspGetSiteChanges @ChangeVersion = ?
    With:
    In my second data flow task, I use the same command and parameter mappings and it fails, very strange.

  • XML SQL - query the table with XML in column [urgent]

    I have table which have to be query-ied with
    oracle.xml.sql.query.OracleXMLQuery class to produce XML
    document for web.
    Problem is that in one column is already XML data (well formed
    HTML) like this:
    <font face="Arial">click</font>
    and when I call OracleXMLQuery.getXMLString() it encode all's '<'
    as ';lt' and so on.
    Can I turn off that kind of encoding some way or is it better
    sollution for this?
    thanks in advance
    Bojan
    null

    You can use an XSLT Stylesheet to achieve what you are wanting to do.
    Say the name of the column containing
    the markup is named "DOC", then
    transforming the output of OracleXMLQuery
    by the following stylesheet using
    the oracle.xml.parser.v2.XSLProcessor...
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl utput method="xml" omit-xml-declaration="yes"/>
    <xsl:template match="@*|node()">
    <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
    </xsl:template>
    <xsl:template match="DOC">
    <xsl:value-of select="." disable-output-escaping="yes"/>
    </xsl:template>
    </xsl:stylesheet>
    Will give the results you are looking for.
    You can use the XSQL Servlet to make this combination even easier if that is applicable to your situation.

  • Issue with SQL Query with Presentation Variable as Data Source in BI Publisher

    Hello All
    I have an issue with creating BIP report based on OBIEE reports which is done using direct SQL. There is this one report in OBIEE dashboard, which is written using direct SQL. To create the pixel perfect version of this report, I am creating BIP data model using SQL Query as data source. The physical query that is used to create OBIEE report has several presentation variables in its where clause.
    select TILE4,max(APPTS), 'Top Count' from
    SELECT c5 as division,nvl(DECODE (C2,0,0,(c1/c2)*100),0) AS APPTS,NTILE (4) OVER ( ORDER BY nvl(DECODE (C2,0,0,(c1/c2)*100),0))  AS TILE4,
    c4 as dept,c6 as month FROM 
    select sum(case  when T6736.TYPE = 'ATM' then T7608.COUNT end ) as c1,
         sum(case  when T6736.TYPE in ('Call Center', 'LSM') then T7608.CONFIRMED_COUNT end ) as c2,
         T802.NAME_LEVEL_6 as c3,
         T802.NAME_LEVEL_1 as c4,
         T6172.CALENDARMONTHNAMEANDYEAR as c5,
         T6172.CALENDARMONTHNUMBERINYEAR as c6,
         T802.DEPT_CODE as c7
    from
         DW_date_DIM T6736 /* z_dim_date */ ,
         DW_MONTH_DIM T6172 /* z_dim_month */ ,
         DW_GEOS_DIM T802 /* z_dim_dept_geo_hierarchy */ ,
         DW_Count_MONTH_AGG T7608 /* z_fact_Count_month_agg */
    where  ( T802.DEpt_CODE = T7608.DEPT_CODE and T802.NAME_LEVEL_1 =  '@{PV_D}{RSD}' 
    and T802.CALENDARMONTHNAMEANDYEAR = 'July 2013'
    and T6172.MONTH_KEY = T7608.MONTH_KEY and T6736.DATE_KEY = T7608.DATE_KEY
    and (T6172.CALENDARMONTHNUMBERINYEAR between substr('@{Month_Start}',0,6)  and substr('@{Month_END}',8,13))
    and (T6736.TYPE in ('Call Center', 'LSM')) )
    group by T802.DEPT_CODE, T802.NAME_LEVEL_6, T802.NAME_LEVEL_1, T6172.CALENDARMONTHNAMEANDYEAR, T6172.CALENDARMONTHNUMBERINYEAR
    order by c4, c3, c6, c7, c5
    ))where tile4=3 group by tile4
    When I try to view data after creating the data set, I get the following error:
    Failed to load XML
    XML Parsing Error: mismatched tag. Expected: . Location: http://172.20.17.142:9704/xmlpserver/servlet/xdo Line Number 2, Column 580:
    Now when I remove those Presention variables (@{PV1}, @{PV2}) in the query with some hard coded values, it is working fine.
    So I know it is the PV that's causing this error.
    How can I work around it?
    There is no way to create equivalent report without using the direct sql..
    Thanks in advance

    I have found a solution to this problem after some more investigation. PowerQuery does not support to use SQL statement as source for Teradata (possibly same for other sources as well). This is "by design" according to Microsoft. Hence the problem
    is not because different PowerQuery versions as mentioned above. When designing the query in PowerQuery in Excel make sure to use the interface/navigation to create the query/select tables and NOT a SQL statement. The SQL statement as source works fine on
    a client machine but not when scheduling it in Power BI in the cloud. I would like to see that the functionality within PowerQuery and Excel should be the same as in Power BI in the cloud. And at least when there is a difference it would be nice with documentation
    or more descriptive errors.
    //Jonas 

  • SQL Query with wrong result

    Hello.
    I have a query with LEFT OUTER JOIN that I think returns invalid results. Here are the problem details:
    CREATE TABLE DOGERR(
    IdDog INTEGER,
    SfPdg CHAR(1),
    IdVpl INTEGER,
    SfVpGot INTEGER,
    SfZrr CHAR(1)
    INSERT INTO DOGERR(IdDog, SfPdg, IdVpl, SfVpGot, SfZrr) VALUES (1, 'S', 1, 1, '7');
    INSERT INTO DOGERR(IdDog, SfPdg, IdVpl, SfVpGot, SfZrr) VALUES (2, 'S', 1, 1, '7');
    INSERT INTO DOGERR(IdDog, SfPdg, IdVpl, SfVpGot, SfZrr) VALUES (3, '$', 1, 2, 'C');
    COMMIT;
    CREATE UNIQUE INDEX DOGERR_PK ON DOGERR(IdDog);
    And now the query:
    SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGotJoin, T.SfZrr AS SfZrrJoin
    FROM DOGERR D
    LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S' OR SfPdg = 'S') T ON
    T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
    WHERE
    D.IdDog = 3
    AND D.SfVpGot = 2
    AND D.SfZrr = 'C';
    This query should (by my understanding) return only one row in wich the joined subquery columns should be NULL. And indeed query returns only one row on Oracle Database 10g Release 10.2.0.1.0 - Production and on Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production:
    IDDOG = 3, SFPDG = "$", IDVPL = 1, SFVPGOT = 2, SFZRR = "C", IDVPLJOIN = NULL, SFVPGOTJOIN = NULL, SFZRRJOIN = NULL
    But on Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production it returns TWO rows:
    IDDOG = 3, SFPDG = "$", IDVPL = 1, SFVPGOT = 2, SFZRR = "C", IDVPLJOIN = 1, SFVPGOTJOIN = 1, SFZRRJOIN = "7"
    IDDOG = 3, SFPDG = "$", IDVPL = 1, SFVPGOT = 2, SFZRR = "C", IDVPLJOIN = 1, SFVPGOTJOIN = 1, SFZRRJOIN = "7"
    And now the interesting part: any of the following modified versions of query works even on Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production, although modifications should not modify the result set:
    -- Removed unnecessary WHERE conditions
    SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGotJoin, T.SfZrr AS SfZrrJoin
    FROM DOGERR D
    LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S' OR SfPdg = 'S') T ON
    T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
    WHERE
    D.IdDog = 3;
    -- Removed unnecessary OR condition in subquery
    SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGotJoin, T.SfZrr AS SfZrrJoin
    FROM DOGERR D
    LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S') T ON
    T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
    WHERE
    D.IdDog = 3
    AND D.SfVpGot = 2
    AND D.SfZrr = 'C';
    -- Removed columns from joined subquery from SELECT part
    SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGotJoin
    FROM DOGERR D
    LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S' OR SfPdg = 'S') T ON
    T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
    WHERE
    D.IdDog = 3
    AND D.SfVpGot = 2
    AND D.SfZrr = 'C';
    NOTE: the query itself is a little stupid but this is just to demonstrate the problem. We have faced this problem at a customer with our real-world query.
    So, my question is: why different results ?
    Thanks.
    David

    hi,
    welcome to the forum,
    don't have a solution, but I thought I'd let you know that the first SQL statement only returns 1 row on 10gR2
    SQL> SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGo
    tJoin, T.SfZrr AS SfZrrJoin
      2  FROM DOGERR D
      3  LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S' OR SfPdg = 'S') T ON
      4  T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
      5  WHERE
      6  D.IdDog = 3
      7  AND D.SfVpGot = 2
      8  AND D.SfZrr = 'C';
         IDDOG S      IDVPL    SFVPGOT S  IDVPLJOIN SFVPGOTJOIN S
             3 $          1          2 C
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production

  • Dynamic SQL Statement with table name

    Dear all
    i like to have a SQL statement with a dynamic tablename. Is this possible? If yes, how?
    should be something like "select * from <mytablename>"
    Thank you
    Herbert

    Yes this is possible. use the below reference code for this.
    data: g_tablename type w_tabname,
            gv_dref TYPE REF TO data.
    FIELD-SYMBOLS: <g_itab> TYPE STANDARD TABLE.
    gv_tabname = p_tablename (take table name form selection screen or as per ur requirement)
    CREATE DATA gv_dref TYPE TABLE OF (g_tabname).
    ASSIGN gv_dref->* TO <g_itab>.
    now use the below select query to fetch the data
      SELECT * FROM (gv_tabname) INTO TABLE <g_itab>.
    Hope this will help

Maybe you are looking for

  • Insert items in list fastly

    Hi, Using SharePoint object model is there is any way to bulk insert items in list fast. I have 10000 records. Thanks, Siva.

  • IAP Sandbox error: payment info verification required

    I am testing my app against IAP sandbox, but it suddenly started asking for payment info verification. (I'm running this on simulator) Eroror message: Verification Required Before you can make purchases, you must tap Continue to verify your payment i

  • Planning object structure

    Dear friends, in a new APO system i want to create planning object structure. when i tried to create planning object structure i got an error saying Invalid planning object structure. its just not letting me create POS. pls guide. Thanks

  • Request: UEFI GOP BIOS N660-2GD5/OC

    Hello! Is there a UEFI GOP BIOS available for my card? SN: 602-V287-090B1305056207 Which bios is compatible with my card ? NV287MH.201 or NV287MH.211 or NV287MH.221?

  • Do Siebel Applications come with demo data like Vision data for EBS??

    Hi All, I am pretty new to Siebel Business Applications. I am trying to install Siebel 8.1.1.5 on a VM and would like to do an Oracle BI Applications ETL to build data warehouse. For this I need some demo data in the Siebel source system. For Oracle