Decode in the select Statement
Hi All,
I am using the decode function in the select statement....but as i am using the group by in the select statement....i am not able to run the same query
How to tackle this problem of handling the decode ....while we have group by also.
This is bit urgent
Thanks for your help
Ramya
Hi,
Thanks for the quick reply.
Here is the code...i have included the decode for the customer carrier code...
SELECT c.trx_number invoice_number,
c.trx_date invoice_date,
ctl.sales_order_date order_date,
c.ship_date_actual ship_date,
c.purchase_order,
ctl.sales_order order_number,
olv.ordered_item item,
msi.description item_description,
olv.ordered_quantity quantity,
olv.unit_selling_price unit_price,
olv.unit_selling_price * olv.ordered_quantity amount,
olv.tax_value,
rc.customer_number,
csta.customer_carrier_code,
(SELECT decode(customer_carrier_code, NULL, 'Shipping & Handling', 'Shipping') sh
FROM xx_cust_ship_to_addresses_v cstaa,
ra_addresses ara
WHERE cstaa.location_id = ad.location_id
AND ara.location_id = ad.location_id) SH,
rc.customer_name invoice_to_name,
rct.name invoice_type,
olv.sold_to,
olv.ship_to_location,
olv.ship_to_address1,
olv.ship_to_address2,
SUBSTR(olv.ship_to_address5, LENGTH(olv.ship_to_address5) -2, LENGTH(olv.ship_to_address5)) ship_to_country,
SUBSTR(olv.ship_to_address5, LENGTH(olv.ship_to_address5) -9, 6) ship_to_postalcode,
SUBSTR(olv.ship_to_address5, LENGTH(olv.ship_to_address5) -12, 2) ship_to_state,
SUBSTR(olv.ship_to_address5, 1, LENGTH(olv.ship_to_address5) -15) ship_to_city,
olv.invoice_to_address1,
olv.invoice_to_address2,
SUBSTR(olv.invoice_to_address5, LENGTH(olv.invoice_to_address5) -2, LENGTH(olv.invoice_to_address5)) invoice_to_country,
SUBSTR(olv.invoice_to_address5, LENGTH(olv.invoice_to_address5) -9, 6) invoice_to_postalcode,
SUBSTR(olv.invoice_to_address5, LENGTH(olv.invoice_to_address5) -12, 2) invoice_to_state,
SUBSTR(olv.invoice_to_address5, 1, LENGTH(olv.invoice_to_address5) -15) invoice_to_city,
olv.flow_status_code,
olv.terms net_terms,
olv.freight_terms_code freight_terms,
olv.fob_point_code fob
FROM ra_customer_trx_all c,
ra_customer_trx_lines_all ctl,
ra_cust_trx_types rct,
jtf_rs_salesreps rs,
ra_customers rc,
ra_addresses ad,
ra_site_uses su,
mtl_system_items msi,
oe_order_headers_v ohv,
oe_order_lines_v olv,
rcv_lot_transactions tl,
rcv_shipment_lines sl,
rcv_shipment_headers rsh,
rcv_transactions rt,
wsh_delivery_details wdd,
xx_cust_ship_to_addresses_v csta
WHERE to_char(ohv.order_number) = ctl.sales_order
AND ctl.customer_trx_id = c.customer_trx_id
AND c.cust_trx_type_id = rct.cust_trx_type_id
AND c.org_id = rs.org_id
AND c.primary_salesrep_id = rs.salesrep_id
AND c.ship_to_site_use_id = su.site_use_id
AND su.address_id = ad.address_id
AND ad.customer_id = rc.customer_id
AND ctl.inventory_item_id = msi.inventory_item_id
AND ohv.header_id = olv.header_id
AND olv.line_id = wdd.source_line_id(+)
AND to_char(olv.line_id) = ctl.interface_line_attribute6
AND tl.shipment_line_id = sl.shipment_line_id
AND sl.shipment_header_id = rsh.shipment_header_id
AND tl.transaction_id = rt.transaction_id
AND csta.location_id = ad.location_id;
GROUP BY c.trx_number,
csta.customer_carrier_code,
c.trx_date,
c.creation_date,
c.ship_date_actual,
c.sold_to_customer_id,
c.bill_to_customer_id,
c.bill_to_site_use_id,
c.ship_to_customer_id,
c.ship_to_site_use_id,
c.purchase_order,
(SELECT decode(customer_carrier_code, NULL, 'Shipping & Handling', 'Shipping') sh
FROM xx_cust_ship_to_addresses_v cstaa,
ra_addresses ara
WHERE cstaa.location_id = ara.location_id
AND ara.location_id = ad.location_id),
ctl.sales_order,
ctl.sales_order_date,
ctl.tax_rate,
ctl.customer_trx_id,
ctl.taxable_amount,
rc.customer_number,
olv.ordered_item,
olv.unit_selling_price,
olv.unit_list_price,
olv.tax_value,
olv.unit_cost,
olv.ordered_quantity,
rs.name,
rc.customer_name,
rc.customer_id,
rc.party_id,
rc.party_number,
ad.address_id,
rct.name,
msi.description,
olv.unit_selling_price * olv.ordered_quantity,
c.org_id,
ohv.header_id,
olv.sold_to,
olv.ship_from,
olv.ship_to_location,
olv.ship_to_address1,
olv.ship_to_address2,
SUBSTR(olv.ship_to_address5, LENGTH(olv.ship_to_address5) -2, LENGTH(olv.ship_to_address5)),
SUBSTR(olv.ship_to_address5, LENGTH(olv.ship_to_address5) -9, 6),
SUBSTR(olv.ship_to_address5, LENGTH(olv.ship_to_address5) -12, 2),
SUBSTR(olv.ship_to_address5, 1, LENGTH(olv.ship_to_address5) -15),
olv.invoice_to_location,
olv.invoice_to_address1,
olv.invoice_to_address2,
SUBSTR(olv.invoice_to_address5, LENGTH(olv.invoice_to_address5) -2, LENGTH(olv.invoice_to_address5)),
SUBSTR(olv.invoice_to_address5, LENGTH(olv.invoice_to_address5) -9, 6),
SUBSTR(olv.invoice_to_address5, LENGTH(olv.invoice_to_address5) -12, 2),
SUBSTR(olv.invoice_to_address5, 1, LENGTH(olv.invoice_to_address5) -15),
olv.flow_status_code,
olv.terms,
olv.freight_terms_code,
olv.shipping_method_code,
olv.fob_point_code,
olv.line_id,
rsh.attribute1,
rsh.attribute2,
su.tax_code,
su.ship_via,
wdd.tracking_number
ORDER BY invoice_number;
Similar Messages
-
Issue with Past Month data in the Select Statement
Hi,
I written the following query,
SELECT /*+NO_MERGE(A)*/
CASE
WHEN snap_shot_date > a.q3
AND snap_shot_date <= a.q4
THEN q4char
WHEN snap_shot_date > a.q2 AND snap_shot_date <= a.q3
THEN q3char
WHEN snap_shot_date > a.q1 AND snap_shot_date <= a.q2
THEN q2char
WHEN snap_shot_date > a.q0 AND snap_shot_date <= a.q1
THEN q1char
END snap_shot_date,
CASE
WHEN snap_shot_date > a.q3 AND snap_shot_date <= a.q4
THEN 1
WHEN snap_shot_date > a.q2 AND snap_shot_date <= a.q3
THEN 2
WHEN snap_shot_date > a.q1 AND snap_shot_date <= a.q2
THEN 3
WHEN snap_shot_date > a.q0 AND snap_shot_date <= a.q1
THEN 4
END sort_by,
pillar3_exposure_class_code, pd_band_description,
ROUND (SUM (p3.ead_post_sec_post_crm)),
ROUND (SUM (notional_principle)),
DECODE (SUM (notional_principle),
0, 0,
ROUND ( SUM (DECODE (exposure_type,
'UNDRAW', ead_post_sec_post_crm,
0
/ SUM (notional_principle),
4
DECODE (SUM (p3.ead_post_sec_post_crm),
0, 0,
ROUND ( SUM (pd_value * p3.ead_post_sec_post_crm)
/ SUM (p3.ead_post_sec_post_crm),
2
DECODE (SUM (p3.ead_post_sec_post_crm),
0, 0,
ROUND (SUM (rwa) / SUM (p3.ead_post_sec_post_crm), 4)
DECODE (SUM (p3.ead_post_sec_post_crm),
0, 0,
ROUND ( SUM (lgd_rate * p3.ead_post_sec_post_crm)
/ SUM (p3.ead_post_sec_post_crm),
2
TO_CHAR (MAX (a.max_date), 'FMMonth DD, YYYY')
FROM summary.pillar3 p3,
(SELECT DISTINCT (month_end_date) max_date,
LAST_DAY (month_end_date) q4,
TO_CHAR (LAST_DAY (month_end_date),
'MON YYYY'
) q4char,
ADD_MONTHS (LAST_DAY (month_end_date), -3) q3,
TO_CHAR
(ADD_MONTHS (LAST_DAY (month_end_date), -3),
'MON YYYY'
) q3char,
ADD_MONTHS (LAST_DAY (month_end_date), -6) q2,
TO_CHAR
(ADD_MONTHS (LAST_DAY (month_end_date), -6),
'MON YYYY'
) q2char,
ADD_MONTHS (LAST_DAY (month_end_date), -9) q1,
TO_CHAR
(ADD_MONTHS (LAST_DAY (month_end_date), -9),
'MON YYYY'
) q1char,
ADD_MONTHS (LAST_DAY (month_end_date), -12) q0
FROM rcdwstg.stg_bcar_detail) a
WHERE snap_shot_date BETWEEN ADD_MONTHS (a.max_date, -12) AND a.max_date
GROUP BY CASE
WHEN snap_shot_date > a.q3 AND snap_shot_date <= a.q4
THEN q4char
WHEN snap_shot_date > a.q2 AND snap_shot_date <= a.q3
THEN q3char
WHEN snap_shot_date > a.q1 AND snap_shot_date <= a.q2
THEN q2char
WHEN snap_shot_date > a.q0 AND snap_shot_date <= a.q1
THEN q1char
END,
CASE
WHEN snap_shot_date > a.q3 AND snap_shot_date <= a.q4
THEN 1
WHEN snap_shot_date > a.q2 AND snap_shot_date <= a.q3
THEN 2
WHEN snap_shot_date > a.q1 AND snap_shot_date <= a.q2
THEN 3
WHEN snap_shot_date > a.q0 AND snap_shot_date <= a.q1
THEN 4
END,
pillar3_exposure_class_code,
pd_band_description
ORDER BY 2 DESC;I have written the query to get the latest 12 months data from a table and split that into 4 quarter to show in the Cognos Report. But when the table having 13th or the past months data, the select statement is showing Empty values in the first two columns and fetching the 13 month data too.
Can anyone help me in this to avoid the problem.
Thanks
Radha KWHERE snap_shot_date BETWEEN ADD_MONTHS(TRUNC(a.max_date, 'MM'), -11) AND a.max_date
.... -
If I want to order by dateAdded to I have to include it in the select statement like
If I do this:
<cfquery name="chart" datasource="#datasource#">
select behaviourID,score, dateAdded2 = convert(varchar,
dateAdded , 101)
from staff_charts_data
where userID =
<cfqueryparam value="#arguments.userID#"
cfsqltype="cf_sql_integer"> AND
NOT score = 5
</cfquery>
If I want to order by dateAdded to I have to include it in
the select statement like so:
<cfquery name="chart" datasource="#datasource#">
select behaviourID,score, dateAdded2 = convert(varchar,
dateAdded , 101),dateAdded
from staff_charts_data
where userID =
<cfqueryparam value="#arguments.userID#"
cfsqltype="cf_sql_integer"> AND
NOT score = 5
</cfquery>you should be able to order by dateAdded without it being in
the select clause. The only time the order by field has to be in
the select clause is when your query has an aggregate and group by
clause, like this:
select field1, field2, max(field3) as youralias
from sometables
where whatever
group by field1, field2
order by ???
You can only order field1, field2, max(field3) or youralias.
You can't order by field4. -
How can I call a Page Process from the Select statement for Report Page
I'm able to call a javascript using the below:
img src="#IMAGE_PREFIX#add2.gif" border="0" alt="Icon 4" onClick="javascript:add_connect1('||CPORT.ID||')"
But Now,
I'd like to accomplish (2) New things:
1. instead of using,....... onClick="javascript:add_connect1,
I'd like to call a Page Process, onClick=
2. I'd like to be able to call two different processes onClick.
a. onClick="javascript:passBack('||ID||')"
b. onClick= <Please see my question #1 above>
Can someone please help me with the syntax for this,
If indeed it can even be done?
Thanks- GaryGreg.
It seems that my situation is the one you describe in you second paragraph, where you mention:
you could then add the ID column value as a parameter to the javascript functionBut,
I do not know how to reference the variable in my javascript nor how to use it in my on-demand process.
If you can hellp me past this last little bump, then I think I will be able to use these skills in Sooo many different areas of my design.
Here's what I've got so far:
A. In the select statement I identify the javascript as:
onClick="javascript:connect_port('<font color=blue>''||ID||''</font>')";
B. In my javascript I have this:
<script language="JavaScript" type="text/javascript">
function connect_port(ID)
var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=CONNECT_PORT',0);
gReturn = get.get();
get = null;
</script>
C. In my on demand function I have this:
BEGIN
INSERT INTO CCONNECTIONS_B
BLDG_ID,CLST_ID,PORT_ID,STRAND_ID
) VALUES
:P2004_BLDG_ID,:P2004_CLST_ID,:P2004_PORT_ID,:P2004_STRAND_ID1
END;
You can see that I dont know how to use the value for 'ID' in either the javascript or the On-Process function.
If you can help me out with this one, Then I can imitate it for the rest.
-Gary
Edited by: garyNboston on Apr 3, 2009 6:44 AM
Edited by: garyNboston on Apr 3, 2009 6:44 AM
Edited by: garyNboston on Apr 3, 2009 6:45 AM
Edited by: garyNboston on Apr 3, 2009 6:47 AM -
Case sensitive statement in the select-statement
Hi All,
i have a table in the abap-dictionary filled with names...when i try to select them with the select-statement with condition:
table-name_column like 'some_name'
I have encountered some problems...the inquiry is case-sensitive. What i want to do is to read the value from the abap-dictionary table uppercase or lowercase and compare it with the needed value also translated in uppercase or lowercase.
The only idea i have is to select all values of the dictionary table into an internal table and to translate the values there in uppercase or lowercase and then to loop trough it. But this approach would cost a lot of performance.
Do someone has an other proposal?check...
Select statement
It would be difficult , because it is based on how data is stored in the data base , now consider the scenario of the system i am using , we can material description as 'test' or 'TEST' , 'Test' .
If in your system there are only stored in either caps or small the you can perform the select twice .
But i myself dont find it to be such a good solution , but you can give it a try
There is one more solution specific to material description ,and that is in the table MAKT there is a field MAKTG , which stored the description in uppercase , so for this you can first convert the description to uppercase and then perform select on this field -
How to test the select statement.
Hi All,
How to test the select statement.
Is there any Oracle sqlplus or toad kind of tool to test the query.
thanks
sivaUse SQL Trace (ST05) and choose 'Explain one SQL Request'. Enter your SQL command as it should be executed in the underlying database. e.g. if the db is Oracle, the statement should be entered as:
SELECT matnr,werks,lvorm,dispo
FROM marc
WHERE mandt = :a AND
matnr = :b AND
werks = :c
In the above :a, :b and :c are place holders for the actual comparison values. You dont have to enter those values. When you choose 'Explain' button, you will find the 'Execution Plan'. The important parameter which denotes the efficiency of the SQL statement is the 'Cost'. The cost should be as low as possible. The table access should be through INDEX UNIQUE SCAN. If you get a FULL TABLE SCAN and higher cost, you need to fine-tune your statement by modifying the where clause.
If you dont know Oracle SQL statements, execute the program in trace mode and go to the trace and you will find the underlying SQL statements issued to the database.
Regards
Suresh Radhakrishnan -
Need a help in the Select statement
How to use the table name dynamically in the Select Statement in Oracle 9.i ?
This?
sql>
select *
from &table
old 2: from &table
new 2: from dual
D
X
Or this..?
sql>
declare
tab varchar2(31) := 'dual';
v varchar2(10);
begin
execute immediate 'select * from '||tab into v;
dbms_output.put_line(v);
end;
X
PL/SQL procedure successfully completed
jeneesh -
Restricting records in the select statement
Hi,
I have one requirement where in i need to restrict my select statement to get only 250 records in the output table.
Here are the select statements i am using....
SELECT a~ebeln
a~lifnr
a~ekgrp
b~werks
b~matnr
FROM ekko AS a INNER JOIN ekpo AS b
ON aebeln = bebeln
INTO TABLE i_ekko
WHERE a~ebeln IN r_ebeln AND
a~lifnr IN r_lifnr AND
a~ekgrp IN r_ekgrp AND
b~werks IN r_ewerk AND
b~matnr IN r_matnr AND
a~bstyp = 'F'.
IF NOT i_ekko[] IS INITIAL.
Select Vendor name
SELECT lifnr
name1
FROM lfa1
INTO TABLE i_lfa1
FOR ALL ENTRIES IN i_ekko
WHERE lifnr = i_ekko-lifnr.
Here if i restrict the first select statement to get only 250 records then i am not getting the desired record in the second select statement.
Could anyone let me know how to write the select statement.
Regards,
Rameshrestric the first select using up to 250.
sort the i_ekko by vendor name.
ex: sort i_ekko by lifnr.
use second select statement here. -
Hi,
Is it possible to use column aliases in the select statement for a database adapter to return an xml element name which is different to the column in the queried table?
I have tried using
SELECT EMPLOYEE_ID, FIRST_NAME AS MYNAME, LAST_NAME, SALARY, DEPARTMENT_ID, PHONE_NUMBER, EMAIL, HIRE_DATE FROM HR.EMPLOYEES WHERE (DEPARTMENT_ID = #DEPT_ID)
but I get the following XML fragment returned
<Employees>
<employeeId>100</employeeId>
<firstName xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<lastName>King</lastName>
<salary>24000</salary>
Any pointers appreciated.
Joel.That is really interesting.
When I use the "custom sql" option in the DB adapter wizard, it used the aliases just fine in the return schema.
Marc -
Problem in the select statement
I have to select the values of the fields BEZEI depending on tha sales order number vbeln. HOw can i write the select statement what will be the tables associated?
Hi,
tables: vbak.
types: begin of ty_vbak,
vbeln type vbeln,
kokrs type kokrs,
end of ty_vbak,
begin of ty_it_tka01,
kokrs type kokrs,
bezei type bezei,
end of ty_tka01.
data: it_vbak type table of ty_vbak,
wa_vbak type ty_vbak,
it_tka01 type table of ty_tka01,
wa_tka01 type ty_tka01.
Select-options: s_vbeln for vbak-vbeln.
Select VBELN KOKRS from VBAK into table it_VBAK where vbeln in s_vbeln.
if sy-subrc = 0.
select KOKRS BEZEI from TKA01 into it_tka01 for all entries in it_vbak where kokrs = it_vbak-kokrs.
endif.
Loop at it_vbak into wa_vbak.
read table it_tka01 into wa_tka01 with key kokrs = wa_vbak-kokrs.
if sy-subrc = 0.
* Move data to final internal table.
endif.
endloop.
Regards,
Satish -
How to find the select statement has written all selected values into text
Hi,
I am using form6i. i am selecting a set of values from database tables based upon some user parameters and writing into the text file using Text_io.put_line . In this case how we can make sure that the text fille contains all the data what we are selected from selected statement. somebody told that there might be chances of aborting of data while writing into the text file. is there any way to fild out the selected statements has written all the selected fields and corresponding output into the .txt file.
Please suggest me.somebody told that there might be chances of aborting of data while writing into the text fileWhat kind of "chance" does that somebody refer to?
If you want to verify if the number of records (lines) in the file matches the number of records from the cursor, you could re-open the written file in read-mode and count the number of lines by reading one by one, then compare the number of lines with the number of records from the cursor. -
Break the SELECT statement.
Hi,
My requirement is to break the Select statement and get the fields in where clause in one internal table.
For eg: Select VBELN
POSNR
MATNR from VBAP into wa_vbap where VBELN = '0000000001'
and POSNR = '000010'.
Here i need to put fields VBELN, POSNR, MATNR in one internal table, table name VBAP in second internal table and where clause fields VBELN, POSNR in third internal table.
Please let me know if anyone has any solution for this.
Thanks in advance.
Sunanda.Hi
*& Report YSELECT *
REPORT YSELECT .
*Select VBELN
*POSNR
*MATNR from VBAP into wa_vbap where VBELN = '0000000001'
*and POSNR = '000010'.
*Here i need to put fields VBELN, POSNR, MATNR in one internal table,
*table name VBAP in second internal table and where clause fields VBELN,
* POSNR in third internal table.
TABLES: VBAP.
TYPES: BEGIN OF STRUCT1,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
MATNR LIKE VBAP-MATNR,
END OF STRUCT1.
TYPES: BEGIN OF STRUCT2,
TBLNAME(10),
END OF STRUCT2.
TYPES: BEGIN OF STRUCT3,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
END OF STRUCT3.
DATA: ITAB1 TYPE TABLE OF STRUCT1 WITH HEADER LINE,
ITAB2 TYPE TABLE OF STRUCT2 WITH HEADER LINE,
ITAB3 TYPE TABLE OF STRUCT3 WITH HEADER LINE,
V_TBLNAME(10).
ITAB3-VBELN = '0000000001'.
ITAB3-POSNR = '000010'.
APPEND ITAB3.
LOOP AT ITAB3.
SELECT VBELN POSNR MATNR FROM VBAP INTO TABLE ITAB1 WHERE VBELN EQ
ITAB3-VBELN AND POSNR EQ ITAB3-POSNR.
WRITE ITAB1-VBELN.
ENDLOOP.
WRITE: 'SUBRC=', SY-SUBRC.
I am unable to find out how to satisfy your second internal table requirement.
Hope this helps
Regards,
Jayanthi.K -
Can we write the select statement on maintence view for data retreval
Can we use the select statement on maintence view
Regrads
DivaNo. U cannot write a select on maintenance view.
-
Substring in the select statement
Hi,
Have a table with 5 columns in it...
Table A
col1
col2
col3
col4
col5
Want to retrieve some columns from that table using the select query, in which substring will be used to extract a part of string from each value contained in the col3 on executing select statement.
How to use the substring in the select statement to perform the above?
RegardsWhat's wrong with <tt>SUBSTR(col3,4,2)</tt> etc? What do the other columns have to do with it?
-
Calling an SP takes over 200% more time over the select statement
As part of my POC converting a SQL Server application over to SAP HANA, I'm find that CALL is taking over 200% more time than calling the SELECT statement directly. The result is that the application that uses ODBC against HANA with CALL statements is taking much more time than SQL Server. I'm finding this for all stored procedure calls in the application. Here is an example:
CREATE PROCEDURE dbo.usp_GetOrdersByCustomerID
(IN C_ID bigint)
LANGUAGE SQLSCRIPT DEFAULT SCHEMA "DBO" READS SQL DATA
AS BEGIN
SELECT TOP 20
C_F_NAME,
C_L_NAME,
C_EMAIL,
O_ID,
O_TOTAL,
O_DTS,
O_FM_DTS
FROM dbo.Customer JOIN dbo.Orders ON C_ID = O_C_ID
WHERE C_ID = :C_ID
ORDER BY O_ID DESC;
END;
When using the following CALL statement in SAP HANA Studio
CALL dbo.usp_GetOrdersByCustomerID(3429);
I get execution times that look like this:
Statement 'CALL dbo.usp_GetOrdersByCustomerID(3429)'
successfully executed in 9 ms 663 µs (server processing time: 8 ms 115 µs)
Fetched 5 row(s) in 0 ms 69 µs (server processing time: 0 ms 0 µs)
Statement 'CALL dbo.usp_GetOrdersByCustomerID(3429)'
successfully executed in 11 ms 851 µs (server processing time: 8 ms 238 µs)
Fetched 5 row(s) in 0 ms 62 µs (server processing time: 0 ms 0 µs)
Statement 'CALL dbo.usp_GetOrdersByCustomerID(3429)'
successfully executed in 8 ms 522 µs (server processing time: 6 ms 892 µs)
Fetched 5 row(s) in 0 ms 93 µs (server processing time: 0 ms 0 µs)
When I execute the select statement with the hard coded parameter value, I get much faster results:
Statement 'SELECT TOP 20 C_F_NAME, C_L_NAME, C_EMAIL, O_ID, O_TOTAL, O_DTS, O_FM_DTS FROM dbo.Customer JOIN ...'
successfully executed in 4 ms 430 µs (server processing time: 2 ms 424 µs)
Fetched 5 row(s) in 0 ms 73 µs (server processing time: 0 ms 0 µs)
Statement 'SELECT TOP 20 C_F_NAME, C_L_NAME, C_EMAIL, O_ID, O_TOTAL, O_DTS, O_FM_DTS FROM dbo.Customer JOIN ...'
successfully executed in 4 ms 105 µs (server processing time: 2 ms 210 µs)
Fetched 5 row(s) in 0 ms 69 µs (server processing time: 0 ms 0 µs)
Statement 'SELECT TOP 20 C_F_NAME, C_L_NAME, C_EMAIL, O_ID, O_TOTAL, O_DTS, O_FM_DTS FROM dbo.Customer JOIN ...'
successfully executed in 4 ms 694 µs (server processing time: 2 ms 810 µs)
Fetched 5 row(s) in 0 ms 60 µs (server processing time: 0 ms 0 µs)
I have 500,000 rows in the Customers table and 2,500,000 rows in the Orders table. The tables are COLUMN tables.
Is there an optimization that I'm missing?
Regards,
BillHi Bill,
Can you please try something:
tab_cust =
SELECT
C_F_NAME,
C_L_NAME,
C_EMAIL
FROM dbo.Customer
WHERE C_ID = :C_ID;
tab_orders =
SELECT
O_ID,
O_TOTAL,
O_DTS,
O_FM_DTS
FROM dbo.Orders ON C_ID = O_C_ID
WHERE O_C_ID = :C_ID
SELECT TOP 20
C_F_NAME,
C_L_NAME,
C_EMAIL,
O_ID,
O_TOTAL,
O_DTS,
O_FM_DTS
FROM :tab_cust JOIN :tab_orders ON C_ID = O_C_ID
ORDER BY O_ID DESC;
END;
Expected behavior: The data set for each of the tables is filtered out and then joined. Although the filter is expected to be pushed to each of the joined tables even in your case, but this is worth the try.
Regards,
Ravi
Maybe you are looking for
-
It just says Failed to open page. Where should I go from here?
-
Hello, I want to make a field that accepts numbers only, I found Best way to prevent users from inputing special characters But in the example there I can add slashes, multiple "-" & ".". Also I can paste non number characters. Is there away to do th
-
UC_OBJECTS_NOT_CONVERTIBLE - "MOVE src TO dst" problem
Hi experts. I've got problem in my application, which appeared in ECC 6.0. The problem conducts to the following dump: The statement "MOVE src TO dst" requires that the operands "dst" and "src" are convertible. Since this statement is i
-
Update of the 0041 it during the rehiring action
Hi experts! We have a report which calculates the seniority of an employee (years, months, days he worked for the company). Ofcourse this report uses different dates from 0041. Currently during rehiring action all dates are set automaticaly to the ne
-
Error on installing applet into JAVA Simulator
Hello all, i have a very basic question (well...for this you can see how newbie i am...) I'm having problems installing an applet into the simulator. My helloWorld.src file looks like this: powerup; // Select the installer applet 0x00 0xA4 0x04 0x00