SQL Query to fetch records from tables which have 75+ million records
Hi,
I have the explain plan for a sql stmt.Require your suggestions to improve this.
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 340 | 175K| 19075 |
| 1 | TEMP TABLE TRANSFORMATION | | | | |
| 2 | LOAD AS SELECT | | | | |
| 3 | SORT GROUP BY | | 32M| 1183M| 799K|
| 4 | TABLE ACCESS FULL | CLM_DETAIL_PRESTG | 135M| 4911M| 464K|
| 5 | LOAD AS SELECT | | | | |
| 6 | TABLE ACCESS FULL | CLM_HEADER_PRESTG | 1 | 274 | 246K|
PLAN_TABLE_OUTPUT
| 7 | LOAD AS SELECT | | | | |
| 8 | SORT UNIQUE | | 744K| 85M| 8100 |
| 9 | TABLE ACCESS FULL | DAILY_PROV_PRESTG | 744K| 85M| 1007 |
| 10 | UNION-ALL | | | | |
| 11 | SORT UNIQUE | | 177 | 97350 | 9539 |
| 12 | HASH JOIN | | 177 | 97350 | 9538 |
| 13 | HASH JOIN OUTER | | 3 | 1518 | 9533 |
| 14 | HASH JOIN | | 1 | 391 | 8966 |
| 15 | TABLE ACCESS BY INDEX ROWID | CLM_DETAIL_PRESTG | 1 | 27 | 3 |
| 16 | NESTED LOOPS | | 1 | 361 | 10 |
| 17 | NESTED LOOPS OUTER | | 1 | 334 | 7 |
PLAN_TABLE_OUTPUT
| 18 | NESTED LOOPS OUTER | | 1 | 291 | 4 |
| 19 | VIEW | | 1 | 259 | 2 |
| 20 | TABLE ACCESS FULL | SYS_TEMP_0FD9D66C9_DA2D01AD | 1 | 269 | 2 |
| 21 | INDEX RANGE SCAN | CLM_PAYMNT_CLMEXT_PRESTG_IDX | 1 | 32 | 2 |
| 22 | TABLE ACCESS BY INDEX ROWID| CLM_PAYMNT_CHKEXT_PRESTG | 1 | 43 | 3 |
| 23 | INDEX RANGE SCAN | CLM_PAYMNT_CHKEXT_PRESTG_IDX | 1 | | 2 |
| 24 | INDEX RANGE SCAN | CLM_DETAIL_PRESTG_IDX | 6 | | 2 |
| 25 | VIEW | | 32M| 934M| 8235 |
| 26 | TABLE ACCESS FULL | SYS_TEMP_0FD9D66C8_DA2D01AD | 32M| 934M| 8235 |
| 27 | VIEW | | 744K| 81M| 550 |
| 28 | TABLE ACCESS FULL | SYS_TEMP_0FD9D66CA_DA2D01AD | 744K| 81M| 550 |
PLAN_TABLE_OUTPUT
| 29 | TABLE ACCESS FULL | CCP_MBRSHP_XREF | 5288 | 227K| 5 |
| 30 | SORT UNIQUE | | 163 | 82804 | 9536 |
| 31 | HASH JOIN | | 163 | 82804 | 9535 |
| 32 | HASH JOIN OUTER | | 3 | 1437 | 9530 |
| 33 | HASH JOIN | | 1 | 364 | 8963 |
| 34 | NESTED LOOPS OUTER | | 1 | 334 | 7 |
| 35 | NESTED LOOPS OUTER | | 1 | 291 | 4 |
| 36 | VIEW | | 1 | 259 | 2 |
| 37 | TABLE ACCESS FULL | SYS_TEMP_0FD9D66C9_DA2D01AD | 1 | 269 | 2 |
| 38 | INDEX RANGE SCAN | CLM_PAYMNT_CLMEXT_PRESTG_IDX | 1 | 32 | 2 |
| 39 | TABLE ACCESS BY INDEX ROWID | CLM_PAYMNT_CHKEXT_PRESTG | 1 | 43 | 3 |
PLAN_TABLE_OUTPUT
| 40 | INDEX RANGE SCAN | CLM_PAYMNT_CHKEXT_PRESTG_IDX | 1 | | 2 |
| 41 | VIEW | | 32M| 934M| 8235 |
| 42 | TABLE ACCESS FULL | SYS_TEMP_0FD9D66C8_DA2D01AD | 32M| 934M| 8235 |
| 43 | VIEW | | 744K| 81M| 550 |
| 44 | TABLE ACCESS FULL | SYS_TEMP_0FD9D66CA_DA2D01AD | 744K| 81M| 550 |
| 45 | TABLE ACCESS FULL | CCP_MBRSHP_XREF | 5288 | 149K| 5 |
The CLM_DETAIL_PRESTG table has 100 million records and the CLM_HEADER_PRESTG table has 75 million records.
Any gussestions on how to getch huge records from tables of this size will help.
Regards,
Narayan
WITH CLAIM_DTL
AS ( SELECT
ICN_NUM,
MIN (FIRST_SRVC_DT) AS FIRST_SRVC_DT,
MAX (LAST_SRVC_DT) AS LAST_SRVC_DT,
MIN (PLC_OF_SRVC_CD) AS PLC_OF_SRVC_CD
FROM CCP_STG.CLM_DETAIL_PRESTG CD WHERE ACT_CD <>'D'
GROUP BY ICN_NUM),
CLAIM_HDR
AS (SELECT
ICN_NUM,
SBCR_ID,
MBR_ID,
MBR_FIRST_NAME,
MBR_MI,
MBR_LAST_NAME,
MBR_BIRTH_DATE,
GENDER_TYPE_CD,
SBCR_RLTNSHP_TYPE_CD,
SBCR_FIRST_NAME,
SBCR_MI,
SBCR_LAST_NAME,
SBCR_ADDR_LINE_1,
SBCR_ADDR_LINE2,
SBCR_ADDR_CITY,
SBCR_ADDR_STATE,
SBCR_ZIP_CD,
PRVDR_NUM,
CLM_PRCSSD_DT,
CLM_TYPE_CLASS_CD,
AUTHO_NUM,
TOT_BILLED_AMT,
HCFA_DRG_TYPE_CD,
FCLTY_ADMIT_DT,
ADMIT_TYPE,
DSCHRG_STATUS_CD,
FILE_BILLING_NPI,
CLAIM_LOCATION_CD,
CLM_RELATED_ICN_1,
SBCR_ID||0
|| MBR_ID
|| GENDER_TYPE_CD
|| SBCR_RLTNSHP_TYPE_CD
|| MBR_BIRTH_DATE
AS MBR_ENROLL_ID,
SUBSCR_INSGRP_NM ,
CAC,
PRVDR_PTNT_ACC_ID,
BILL_TYPE,
PAYEE_ASSGN_CODE,
CREAT_RUN_CYC_EXEC_SK,
PRESTG_INSRT_DT
FROM CCP_STG.CLM_HEADER_PRESTG P WHERE ACT_CD <>'D' AND SUBSTR(CLM_PRCSS_TYPE_CD,4,1) NOT IN ('1','2','3','4','5','6') ),
PROV AS ( SELECT DISTINCT
PROV_ID,
PROV_FST_NM,
PROV_MD_NM,
PROV_LST_NM,
PROV_BILL_ADR1,
PROV_BILL_CITY,
PROV_BILL_STATE,
PROV_BILL_ZIP,
CASE WHEN PROV_SEC_ID_QL='E' THEN PROV_SEC_ID
ELSE NULL
END AS PROV_SEC_ID,
PROV_ADR1,
PROV_CITY,
PROV_STATE,
PROV_ZIP
FROM CCP_STG.DAILY_PROV_PRESTG),
MBR_XREF AS (SELECT SUBSTR(MBR_ENROLL_ID,1,17)||DECODE ((SUBSTR(MBR_ENROLL_ID,18,1)),'E','1','S','2','D','3')||SUBSTR(MBR_ENROLL_ID,19) AS MBR_ENROLLL_ID,
NEW_MBR_FLG
FROM CCP_STG.CCP_MBRSHP_XREF)
SELECT DISTINCT CLAIM_HDR.ICN_NUM AS ICN_NUM,
CLAIM_HDR.SBCR_ID AS SBCR_ID,
CLAIM_HDR.MBR_ID AS MBR_ID,
CLAIM_HDR.MBR_FIRST_NAME AS MBR_FIRST_NAME,
CLAIM_HDR.MBR_MI AS MBR_MI,
CLAIM_HDR.MBR_LAST_NAME AS MBR_LAST_NAME,
CLAIM_HDR.MBR_BIRTH_DATE AS MBR_BIRTH_DATE,
CLAIM_HDR.GENDER_TYPE_CD AS GENDER_TYPE_CD,
CLAIM_HDR.SBCR_RLTNSHP_TYPE_CD AS SBCR_RLTNSHP_TYPE_CD,
CLAIM_HDR.SBCR_FIRST_NAME AS SBCR_FIRST_NAME,
CLAIM_HDR.SBCR_MI AS SBCR_MI,
CLAIM_HDR.SBCR_LAST_NAME AS SBCR_LAST_NAME,
CLAIM_HDR.SBCR_ADDR_LINE_1 AS SBCR_ADDR_LINE_1,
CLAIM_HDR.SBCR_ADDR_LINE2 AS SBCR_ADDR_LINE2,
CLAIM_HDR.SBCR_ADDR_CITY AS SBCR_ADDR_CITY,
CLAIM_HDR.SBCR_ADDR_STATE AS SBCR_ADDR_STATE,
CLAIM_HDR.SBCR_ZIP_CD AS SBCR_ZIP_CD,
CLAIM_HDR.PRVDR_NUM AS PRVDR_NUM,
CLAIM_HDR.CLM_PRCSSD_DT AS CLM_PRCSSD_DT,
CLAIM_HDR.CLM_TYPE_CLASS_CD AS CLM_TYPE_CLASS_CD,
CLAIM_HDR.AUTHO_NUM AS AUTHO_NUM,
CLAIM_HDR.TOT_BILLED_AMT AS TOT_BILLED_AMT,
CLAIM_HDR.HCFA_DRG_TYPE_CD AS HCFA_DRG_TYPE_CD,
CLAIM_HDR.FCLTY_ADMIT_DT AS FCLTY_ADMIT_DT,
CLAIM_HDR.ADMIT_TYPE AS ADMIT_TYPE,
CLAIM_HDR.DSCHRG_STATUS_CD AS DSCHRG_STATUS_CD,
CLAIM_HDR.FILE_BILLING_NPI AS FILE_BILLING_NPI,
CLAIM_HDR.CLAIM_LOCATION_CD AS CLAIM_LOCATION_CD,
CLAIM_HDR.CLM_RELATED_ICN_1 AS CLM_RELATED_ICN_1,
CLAIM_HDR.SUBSCR_INSGRP_NM,
CLAIM_HDR.CAC,
CLAIM_HDR.PRVDR_PTNT_ACC_ID,
CLAIM_HDR.BILL_TYPE,
CLAIM_DTL.FIRST_SRVC_DT AS FIRST_SRVC_DT,
CLAIM_DTL.LAST_SRVC_DT AS LAST_SRVC_DT,
CLAIM_DTL.PLC_OF_SRVC_CD AS PLC_OF_SRVC_CD,
PROV.PROV_LST_NM AS BILL_PROV_LST_NM,
PROV.PROV_FST_NM AS BILL_PROV_FST_NM,
PROV.PROV_MD_NM AS BILL_PROV_MID_NM,
PROV.PROV_BILL_ADR1 AS BILL_PROV_ADDR1,
PROV.PROV_BILL_CITY AS BILL_PROV_CITY,
PROV.PROV_BILL_STATE AS BILL_PROV_STATE,
PROV.PROV_BILL_ZIP AS BILL_PROV_ZIP,
PROV.PROV_SEC_ID AS BILL_PROV_EIN,
PROV.PROV_ID AS SERV_FAC_ID ,
PROV.PROV_ADR1 AS SERV_FAC_ADDR1 ,
PROV.PROV_CITY AS SERV_FAC_CITY ,
PROV.PROV_STATE AS SERV_FAC_STATE ,
PROV.PROV_ZIP AS SERV_FAC_ZIP ,
CHK_PAYMNT.CLM_PMT_PAYEE_ADDR_LINE_1,
CHK_PAYMNT.CLM_PMT_PAYEE_ADDR_LINE_2,
CHK_PAYMNT.CLM_PMT_PAYEE_CITY,
CHK_PAYMNT.CLM_PMT_PAYEE_STATE_CD,
CHK_PAYMNT.CLM_PMT_PAYEE_POSTAL_CD,
CLAIM_HDR.CREAT_RUN_CYC_EXEC_SK
FROM CLAIM_DTL,(select * FROM CCP_STG.CLM_DETAIL_PRESTG WHERE ACT_CD <>'D') CLM_DETAIL_PRESTG, CLAIM_HDR,CCP_STG.MBR_XREF,PROV,CCP_STG.CLM_PAYMNT_CLMEXT_PRESTG CLM_PAYMNT,CCP_STG.CLM_PAYMNT_CHKEXT_PRESTG CHK_PAYMNT
WHERE
CLAIM_HDR.ICN_NUM = CLM_DETAIL_PRESTG.ICN_NUM
AND CLAIM_HDR.ICN_NUM = CLAIM_DTL.ICN_NUM
AND CLAIM_HDR.ICN_NUM=CLM_PAYMNT.ICN_NUM(+)
AND CLM_PAYMNT.CLM_PMT_CHCK_ACCT=CHK_PAYMNT.CLM_PMT_CHCK_ACCT
AND CLM_PAYMNT.CLM_PMT_CHCK_NUM=CHK_PAYMNT.CLM_PMT_CHCK_NUM
AND CLAIM_HDR.MBR_ENROLL_ID = MBR_XREF.MBR_ENROLLL_ID
AND CLM_DETAIL_PRESTG.FIRST_SRVC_DT >= 20110101
AND MBR_XREF.NEW_MBR_FLG = 'Y'
AND PROV.PROV_ID(+)=SUBSTR(CLAIM_HDR.PRVDR_NUM,6)
AND MOD(SUBSTR(CLAIM_HDR.ICN_NUM,14,2),2)=0
UNION ALL
SELECT DISTINCT CLAIM_HDR.ICN_NUM AS ICN_NUM,
CLAIM_HDR.SBCR_ID AS SBCR_ID,
CLAIM_HDR.MBR_ID AS MBR_ID,
CLAIM_HDR.MBR_FIRST_NAME AS MBR_FIRST_NAME,
CLAIM_HDR.MBR_MI AS MBR_MI,
CLAIM_HDR.MBR_LAST_NAME AS MBR_LAST_NAME,
CLAIM_HDR.MBR_BIRTH_DATE AS MBR_BIRTH_DATE,
CLAIM_HDR.GENDER_TYPE_CD AS GENDER_TYPE_CD,
CLAIM_HDR.SBCR_RLTNSHP_TYPE_CD AS SBCR_RLTNSHP_TYPE_CD,
CLAIM_HDR.SBCR_FIRST_NAME AS SBCR_FIRST_NAME,
CLAIM_HDR.SBCR_MI AS SBCR_MI,
CLAIM_HDR.SBCR_LAST_NAME AS SBCR_LAST_NAME,
CLAIM_HDR.SBCR_ADDR_LINE_1 AS SBCR_ADDR_LINE_1,
CLAIM_HDR.SBCR_ADDR_LINE2 AS SBCR_ADDR_LINE2,
CLAIM_HDR.SBCR_ADDR_CITY AS SBCR_ADDR_CITY,
CLAIM_HDR.SBCR_ADDR_STATE AS SBCR_ADDR_STATE,
CLAIM_HDR.SBCR_ZIP_CD AS SBCR_ZIP_CD,
CLAIM_HDR.PRVDR_NUM AS PRVDR_NUM,
CLAIM_HDR.CLM_PRCSSD_DT AS CLM_PRCSSD_DT,
CLAIM_HDR.CLM_TYPE_CLASS_CD AS CLM_TYPE_CLASS_CD,
CLAIM_HDR.AUTHO_NUM AS AUTHO_NUM,
CLAIM_HDR.TOT_BILLED_AMT AS TOT_BILLED_AMT,
CLAIM_HDR.HCFA_DRG_TYPE_CD AS HCFA_DRG_TYPE_CD,
CLAIM_HDR.FCLTY_ADMIT_DT AS FCLTY_ADMIT_DT,
CLAIM_HDR.ADMIT_TYPE AS ADMIT_TYPE,
CLAIM_HDR.DSCHRG_STATUS_CD AS DSCHRG_STATUS_CD,
CLAIM_HDR.FILE_BILLING_NPI AS FILE_BILLING_NPI,
CLAIM_HDR.CLAIM_LOCATION_CD AS CLAIM_LOCATION_CD,
CLAIM_HDR.CLM_RELATED_ICN_1 AS CLM_RELATED_ICN_1,
CLAIM_HDR.SUBSCR_INSGRP_NM,
CLAIM_HDR.CAC,
CLAIM_HDR.PRVDR_PTNT_ACC_ID,
CLAIM_HDR.BILL_TYPE,
CLAIM_DTL.FIRST_SRVC_DT AS FIRST_SRVC_DT,
CLAIM_DTL.LAST_SRVC_DT AS LAST_SRVC_DT,
CLAIM_DTL.PLC_OF_SRVC_CD AS PLC_OF_SRVC_CD,
PROV.PROV_LST_NM AS BILL_PROV_LST_NM,
PROV.PROV_FST_NM AS BILL_PROV_FST_NM,
PROV.PROV_MD_NM AS BILL_PROV_MID_NM,
PROV.PROV_BILL_ADR1 AS BILL_PROV_ADDR1,
PROV.PROV_BILL_CITY AS BILL_PROV_CITY,
PROV.PROV_BILL_STATE AS BILL_PROV_STATE,
PROV.PROV_BILL_ZIP AS BILL_PROV_ZIP,
PROV.PROV_SEC_ID AS BILL_PROV_EIN,
PROV.PROV_ID AS SERV_FAC_ID ,
PROV.PROV_ADR1 AS SERV_FAC_ADDR1 ,
PROV.PROV_CITY AS SERV_FAC_CITY ,
PROV.PROV_STATE AS SERV_FAC_STATE ,
PROV.PROV_ZIP AS SERV_FAC_ZIP ,
CHK_PAYMNT.CLM_PMT_PAYEE_ADDR_LINE_1,
CHK_PAYMNT.CLM_PMT_PAYEE_ADDR_LINE_2,
CHK_PAYMNT.CLM_PMT_PAYEE_CITY,
CHK_PAYMNT.CLM_PMT_PAYEE_STATE_CD,
CHK_PAYMNT.CLM_PMT_PAYEE_POSTAL_CD,
CLAIM_HDR.CREAT_RUN_CYC_EXEC_SK
FROM CLAIM_DTL, CLAIM_HDR,MBR_XREF,PROV,CCP_STG.CLM_PAYMNT_CLMEXT_PRESTG CLM_PAYMNT,CCP_STG.CLM_PAYMNT_CHKEXT_PRESTG CHK_PAYMNT
WHERE CLAIM_HDR.ICN_NUM = CLAIM_DTL.ICN_NUM
AND CLAIM_HDR.ICN_NUM=CLM_PAYMNT.ICN_NUM(+)
AND CLM_PAYMNT.CLM_PMT_CHCK_ACCT=CHK_PAYMNT.CLM_PMT_CHCK_ACCT
AND CLM_PAYMNT.CLM_PMT_CHCK_NUM=CHK_PAYMNT.CLM_PMT_CHCK_NUM
AND CLAIM_HDR.MBR_ENROLL_ID = MBR_XREF.MBR_ENROLLL_ID
-- AND TRUNC(CLAIM_HDR.PRESTG_INSRT_DT) = TRUNC(SYSDATE)
AND CLAIM_HDR.CREAT_RUN_CYC_EXEC_SK = 123638.000000000000000
AND MBR_XREF.NEW_MBR_FLG = 'N'
AND PROV.PROV_ID(+)=SUBSTR(CLAIM_HDR.PRVDR_NUM,6)
AND MOD(SUBSTR(CLAIM_HDR.ICN_NUM,14,2),2)=0;
Similar Messages
-
SQL query to fetch records from 26 onwards
Want to know SQL query to fetch records from 26 onwards.
See the fifth entry on the FAQ page:
Re: How to attach a java bean in forms6i -
How will write SQL query to fetch data from each Sub-partition..
Hi All,
Anyone does have any idea about How to write SQL query to fetch data from Sub-partition.
Actually i have one table having composite paritition(Range+list)
Now if i want to fetch data from main partition(Range) the query will be
SELECT * FROM emp PARTITION(q1_2005);
Now i want to fetch data at sub-partition level(List) .But i am not able to get any SQL query for that.
Pls help me to sort out.
Thanks in Advance.
AnwarSELECT * FROM emp SUBPARTITION(sp1);
-
RFC fetching data from table which is not commited
Hi Experts,
I have a query regarding commit work.Below is the RFC that i have written
FUNCTION ZBAPI_CREATE.
*"*"Local Interface:
*" TABLES
*" IT_ZABAP_RFC STRUCTURE ZBAPI_RFC_STR OPTIONAL
*" RETURN STRUCTURE BAPIRET2 OPTIONAL
CALL FUNCTION 'ZBO_BAPI_CREATE'
TABLES
IT_ZABAP_RFC = IT_ZABAP_RFC
RETURN = return
Break-point.
DATA lt TYPE TABLE OF ZBAPI_RFC_STR_MAIN.
CALL FUNCTION 'ZBAPI_SEARCH_RANGE'
* EXPORTING
* IS_STR =
TABLES
ET_TAB = lt
* RETURN =
ENDFUNCTION.
here in first RFC call i am creating a record in ZTABLE , and then at break-point
i check the ZTABLE where it does not create any record because data is not commited into ZTABLE upto this point, but just after it i have written code for fetching data from ZTABLE but i am able to get this new record in lt.
Can anybody please explain that from where this serach RFC is providing data because inside serach i am simply selecting data from ZTABLE.
Regards,
Abhishek Bajpai
Edited by: ABHISHEK BAJPAI on Jan 28, 2009 1:12 PMHi Thomas,
Thanks for reply , i checked in ZTABLE ,before search RFC call data is not there but if i commit explicitly only then it is showing data in ZTABLE. Actually my requirement is different -
I have two RFCs 1. Create 2. Search , Now from web dynpro user will call first Create RFCs but at this point it should not insert record in ZTABLE and just after it user will call another search RFC and in this search he should be able to get these newly created records.
I want to have the functionality which a user gets when working with normal database front end like SQLPLus for Oracle. In these scenarios we see that whenever user does any insert or update the data sits in the table but still it is not committed. So there he fires Select query he sees the inserted data. But if he logs off from SQL PLUS and then logs in again, and fires Select query he does not see the data as it was not committed. I want a similiar functionalty in which if user inserts the data through Create RFC and fires the Select query through Search RFC then he can see the newly Created data also even though this data is not committed.
Although if i call create RFC in update task it will not update ZTABLE but in this situation , if user will call search RFC he will not be able to get newly created records.
So my requirement is that i should be able to get those records which are not commited in ZTABLE .If you have still any doubt regarding my question then please let me know.
Regards,
Abhishek -
Please let me know how to write the Query to fetch data from tables
Hi Folks,
Please let me know how to get the data from different tables using the functionality SQ03,SQ02 and SQ01 .
Helpful answers will points awarded.
Regards,
Ram.Dear Ram,
Please find the below link which gives in detail with screen shots.
[SAP Query|http://media.techtarget.com/searchSAP/downloads/Teach_yourself_SAP_C20.pdf#search=%22CREATE%20REPORT%20USING%20SQVI%20%2C%20SAP%22]
Thanks
Murtuza -
Sql query to fetch record datewise and hourwise
I have a table say ABC with column key and date
like
key date
charge 4/11/2009 00:46:20 AM
reload 3/27/2008 12:46:20 AM
auto 3/27/2008 07:46:20 AM
now i want that the count for column key is selected
datewise and hour wise
like for a particular date for hour between
0000-0001
0001-0002
2300-2400
the no of different key column values come
i.e
for date 4.11.09 hour 2300-2400
charge=5
auto=2
reload=8
how could it be acheived
thanks in advanceOk, if you want to get all the data for one particular day, you need to know that the times in the DATE format run from 00:00:00 to 23:59:59 on one day. Therefore there is no concept of 24:00:00 as a time for today, because that's equivalent to 00:00:00 of tomorrow!
If you do:
select keyword, trunc(transaction_time, 'hh'), count(*)
from tid_master
where transaction_time >= to_date('04.11.2009' || ' 0000','mm.dd.yyyy hh24mi')
and transaction_time < to_date('04.11.2009' || ' 0000','mm.dd.yyyy hh24mi') + 1
group by keyword, trunc(transaction_time, 'hh')Then you get all the results for the 11th April 2009. (Side note: please note that I have specified four digits for the year - this is good practice, as "09" could refer to 1909, 2009, 2109, etc, and the db could potentially pick one that you're not expecting! Always be explicit - dates have four digit years, therefore enter them as four digits. The Y2K bug was not all that long ago!).
You'd do the above with a variable like:
select keyword, trunc(transaction_time, 'hh'), count(*)
from tid_master
where transaction_time >= trunc(your_date_variable)
and transaction_time < trunc(your_date_variable) + 1
group by keyword, trunc(transaction_time, 'hh')If you don't have an index on the transaction_time column, then it's ok to do this:
select keyword, trunc(transaction_time, 'hh'), count(*)
from tid_master
where trunc(transaction_time) = trunc(your_date_variable)
group by keyword, trunc(transaction_time, 'hh')You could replace your variable with sysdate etc. -
Select statement from tables which have now been split
I used to select from 3 tables:
user, login, location
I would do:
select distinct user.id, login.computer_id, location.id as location_id
from user, login, location
where user.id = login.user_id
and login.location_id = location.id
and user.id = "manny"
but user has now been split into user1, and user2
I want to pull data where it exists from user1 or user2.
Much of the data in user1 is duplicated in user2 and vice versa, but I want to pull only one instance where it appears so that I can still get single row results of:
ID COMPUTER_ID LOCATION_ID
mannyd redstar_1 Bronx, NY
Any ideas on the query?Why would you split a single table into multiple tables with the same structure and much of the same data? That seems rather counterproductive.
I suppose you could do something like
select user.id, login.computer_id, location.id as location_id
from user1 user, login, location
where user.id = login.user_id
and login.location_id = location.id
and user.id = 'manny'
UNION
select user.id, login.computer_id, location.id as location_id
from user2 user, login, location
where user.id = login.user_id
and login.location_id = location.id
and user.id = 'manny'but that's obviously going to be much more expensive than the single-table approach...
Justin -
Delete records from tableA which are not in tableB
Table A contains milions of records which is the best way to delete records from tableA which are not in tableB
delete from tableA where empno not in (select empno from tableb)
or
delete from tableA where empno not exists (select empno from tableb
where b.empno=a.empno)
any helpHi
If you can do this, do with this:
create table tableC
as select a.*
from tableA a,
(select empno from tableA
minus
select empno from tableB) b
where a.empno = b.empno;
drop table tableA;
rename table tableC to tableA;
Ott Karesz
http://www.trendo-kft.hu -
Output from tables which I mention in select options of the screen as input
Dear All,
I want to fetch the data in the form of output from tables which I will mention in select options of the screen as input.
In selection screen option if I write any table name then how can i select this table in select query of ABAP program ?.
I may select any tables in select options of screen. But In select query I should get that table name automatically.. How ?
e.g. If i put table name as an input i.e. MARA in select option .
In program how to write select query to get records from that table ?
SELECT MTART MATKL from MARA
Every time I should not go to select query of program & replace the tablename.
How to solve this problem ?Hi,
PARAMETERS p_table(30)." type string.
"This is a Tested code Just Execute and Check
START-OF-SELECTION.
DATA: lt_tmp TYPE REF TO data.
DATA : line TYPE REF TO data.
FIELD-SYMBOLS: <lt_tmp> TYPE STANDARD TABLE, <wa>, <dyn_field>.
CREATE DATA lt_tmp TYPE STANDARD TABLE OF (p_table).
ASSIGN lt_tmp->* TO <lt_tmp> .
CREATE DATA line LIKE LINE OF <lt_tmp>.
ASSIGN line->* TO <wa>.
SELECT * FROM (p_table) INTO TABLE <lt_tmp>.
IF sy-subrc = 0.
LOOP AT <lt_tmp> ASSIGNING <wa>.
DO.
ASSIGN COMPONENT sy-index
OF STRUCTURE <wa> TO <dyn_field>.
IF sy-subrc NE 0.
EXIT.
ENDIF.
IF sy-index = 1.
WRITE:/ <dyn_field>.
ELSE.
WRITE: <dyn_field>.
ENDIF.
ENDDO.
ENDLOOP.
ENDIF.
Cheerz
Ram -
Sql Query to store record like warehoue wise items
Hi Experts
I want to ask you a sql query for inserting records from two table OITM and OWHS in a user definded table like OITW.
I have a table BINMASTER in which bin code are stored. Now I want to create a table Like OWHS where BIN Wise Item records to be stored Let See
Item01 Bin 01
Item02 Bin 01
Item03 Bin 01
Item01 Bin 02
Item02 Bin 02
Item03 Bin 02
Plz give your suggestions
Regards
Gorgehi János Nagy
Thank for reply
your statement is fine with no where condition. But I want to insert in a UDT in which Code, Name are two field which should be unique for every record. I use following statement
Insert into (Code, name, Itemcode, ItemDescription, Bincode , Warehouse )
select ?, ?, T1.Itemcode, T2.ItemDescription, T2.Bincode , T3.WhsCode From Oitm T1, T2, Owhs T3
Here what I insert in Code and Name fields
Regards
Gorge -
Fetch value from Table with respect to APP_USER.
Hi,
i want to fetch value from Table with respect to APP_USER.
i am using
SELECT ID,NAME,FILE_OBJ_ID,MIME_TYPE,DOC_SIZE,BLOB_CONTENT,DESCRIPTION,UPLOAD_DATE,'Download' FROM DUMY_FILE where CREATED_BY =:APP_USER;
Show me error
failed to parse SQL query:
ORA-00911: invalid characterThanks
Edited by: 805629 on Jan 13, 2011 2:09 AMHello,
I too have the same problem.
I am using this query:
select manager from leave_mgmt where support_engg=:APP_USER
and source type is SQL Query(return single value)
but nothing is coming up in the text field. Its empty.
Please advice. Thanks in advance. -
SQL query to fetch WIP jobs agains a customer
Hi All,
Can anyone please help me with a SQL query to fetch WIP jobs agains a customer.
Regards,
ShrutiIf you are using ATO functionality and if you are reserving sales orders to work orders, you can link them as follows
Using customer name, identify the open sales order headers and lines.
For each line, query reservations (mtl_reservations) using demand id fields.
For those reservations where supply = wip job, use the supply id fields and get wip_entity_id.
Using wip_entity_id, get wip_entity_name(job#) from wip_entities table.
Once a job is completed, this link is lost.
Sandeep Gandhi -
VB Runtime error timeouts. Could not fetch terms from table: TPW6
VB Runtime error timeouts are occurring repeatedly for multiple users on the terminal server.
Event Type: Warning
Event Source: VBRuntime
Event Category: None
Event ID: 1
Description: The VB Application identified by the event source logged this Application XL Reporter: Thread ID: 13508 ,Logged: Could not fetch terms from table: TPW6
It looks like bad table reference in XL reports? This is causing significant lag as they wait to time-out. Is there a way to identify source(s) and correct it/them? Unfortunately the error does not say what report. Is there any way of identifying exactly what the SAP equivalent is to the tables it is having issues finding?
thanksThis error may not cause big problems. We have to live with it for a long time. It only show XLR with highlight icon on the task bar. It shouldn't have much bigger impacts.
Thanks,
Gordon -
Sql query to get numbers from 0 to 99
How can we write an sql query to get values from 0 to 99 ... this shouldn't be coming from any table
Bawer wrote:
Result: (quickly replied by oracle)
SQL-Error: ORA-30009 (Not enough memory for connect by - 1GB reserved for oracle on VirtualBox)Oracle version? Takes about 8 seconds on my:
SQL> select * from v$version
2 /
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
Elapsed: 00:00:00.14
SQL> select count(*) from (
2 SELECT LEVEL - 1
3 FROM DUAL
4 CONNECT BY LEVEL <= 10000000
5 )
6 /
COUNT(*)
10000000
Elapsed: 00:00:07.76
SQL> SY. -
To remove line items from invoice which have 0 qty.
Dear Friends,
Requirement: To remove line items from invoice which have 0 qty.
For this I wrote the code in RV60AFZZ. It is very well happening, but when last line item comes it is failing.
What I have written is " DELETE XVBRP WHERE FKIMG = '0' ." . This code is deleting all the line items with 0 qty except last line item.
Actually, this exit works line item wise. Once the line item is appended, the code what I have written is working. For the last line item, record is not appended when this exit is triggerred, thats why last record is not deleted.
The include where all line items are getting appended in XVBRP is LV60AB03. I modified this also. Same code I have written here to delete the records once it is appended. But after doing this the problem is - invoice is not getting created.
Please help me in doing this so as to delete this last record also. I tried with other logics also, not able to track the last record.
Please help me to resolve this problem.
Thanks.Hi,
Check user exit RV60AFZC.
RV_INVOICE_DOCUMENT_ADD is the FM which is called to generate number for the invoice after all the line items have been added to vbrp structure. Add a break-point here and check.
All the best.
Regards,
Amit
Maybe you are looking for
-
Partitioning windows 8.1
Hello , I just Took Delivery of a HP touchsmart notebook pc 15-n230sa notebook pc laptop , and have done battle and managed to set it up after a struggle, It comes with a 1tb hardrive which runs windows 8.1 op system , I am writing to ask does anyone
-
Nokia Belle FP1 Pros and Bugs.
I have FP1 installed on my 701. I must say this update is significant improvement from the old belle in terms of features and functionality. I'm happy that Nokia solved most of the problems that I have mentioned earlier. /t5/Nseries-and-Symbian-Smar
-
How to get codes for app.executeCommand() method?
Hi There, I have used some command codes before to get at specific items AE's global menu before, but only because I was able to reference them here on the discussions. For example, to bring up the General Preferences windows, I can use this: app.ex
-
Student account for Adobe CC - downloaded and worked but only for TRIAL - now asks for license - how do I access the programs? I was given a redemption code (apparently redeemed already). How do I get the licensing code?
-
Needs to goto self inbox for approval
Hi All, When we create Shopping cart we need to send a meesage to self Inbox rather line manager or some one. There is no need of check the amount value for approval. If anyone come across for this kind of process it would be appreciated with points