How to comple query to get correct results?
Hello,
I am having problems getting the results from a query. I have 2 tables:
Marriage table
People1ID People2ID DateMarried
1 4 5/5/2014
5 7 6/5/2014
2 3 7/5/2014
People table
PeopleID First Last
1 Bob Jones
2 Mary Smith
3 Steve Smith
4 Jane Jones
5 Robert Apple
6 Julie Jackson
7 Diane Apple
Looking for result like this:
First1 Last1 First2 Last2 DateMarried
Bob Jones Jane Jones 5/5/2014
Robert Apple Diane Apple 6/5/2014
Mary Smith Steve Smith 6/5/2014
Paul
I'm little confuse on your expected result specially on the third row column "Datemarried". Are you sure that its 6/5/2014. I think its 7/5/2014. Anyway you can try this query.
select b.[First], b.[Last],
c.[First],c.[Last],
a.DateMarried from marriage a
left outer join People b
on a.people1id=b.peopleid
left outer join People c
on a.people2id=c.peopleid
this will be the result:
First Last
First Last
DateMarried
Bob Jones
Jane Jones
5/5/2014
Robert Apple
Diane Apple
6/5/2014
Mary Smith
Steve Smith
7/5/2014
Similar Messages
-
HOW TO CHANGE SQL QUERY TO GET SPECIFIC RESULT
I HAVE FOLLOWING QUERY AND ITS FUNCTIONING BUT I WANT ALL THOSE RECORD SHOULD BE DISPLADE WICH HAVE NO TRANSACTION IN SALES ANS SALES RETURN WHILE RETREVING DATA FROM DATABASE.
I TRIED TO USE + OPERATOR BUT I DON'T KNOW HOW TO CHANGE THE QUERY TO GET THE RESULT
MAIN TABLE IS BEING USED TO FETCH RECORD
SALES_HEADER,SALES_DETAIL
SALES_HEADERR,SALES_DETAILR
STOCK_REG
AND THE QUERY IS
select s.item_code,S.DESCR,s.GRAND_TOTAL,
sum(decode(d.dayno,01,NVL(S.QTY,0),0)) DAY1,
sum(decode(d.dayno,02,NVL(S.QTY,0),0)) DAY2,
sum(decode(d.dayno,03,NVL(S.QTY,0),0)) DAY3,
sum(decode(d.dayno,04,NVL(S.QTY,0),0)) DAY4,
sum(decode(d.dayno,05,NVL(S.QTY,0),0)) DAY5,
sum(decode(d.dayno,06,NVL(S.QTY,0),0)) DAY6,
sum(decode(d.dayno,07,NVL(S.QTY,0),0)) DAY7,
sum(decode(d.dayno,08,NVL(S.QTY,0),0)) DAY8,
sum(decode(d.dayno,09,NVL(S.QTY,0),0)) DAY9,
sum(decode(d.dayno,10,NVL(S.QTY,0),0)) DAY10,
sum(decode(d.dayno,11,NVL(S.QTY,0),0)) DAY11,
sum(decode(d.dayno,12,NVL(S.QTY,0),0)) DAY12,
sum(decode(d.dayno,13,NVL(S.QTY,0),0)) DAY13,
sum(decode(d.dayno,14,NVL(S.QTY,0),0)) DAY14,
sum(decode(d.dayno,15,NVL(S.QTY,0),0)) DAY15,
sum(decode(d.dayno,16,NVL(S.QTY,0),0)) DAY16,
sum(decode(d.dayno,17,NVL(S.QTY,0),0)) DAY17,
sum(decode(d.dayno,18,NVL(S.QTY,0),0)) DAY18,
sum(decode(d.dayno,19,NVL(S.QTY,0),0)) DAY19,
sum(decode(d.dayno,20,NVL(S.QTY,0),0)) DAY20,
sum(decode(d.dayno,21,NVL(S.QTY,0),0)) DAY21,
sum(decode(d.dayno,22,NVL(S.QTY,0),0)) DAY22,
sum(decode(d.dayno,23,NVL(S.QTY,0),0)) DAY23,
sum(decode(d.dayno,24,NVL(S.QTY,0),0)) DAY24,
sum(decode(d.dayno,25,NVL(S.QTY,0),0)) DAY25,
sum(decode(d.dayno,26,NVL(S.QTY,0),0)) DAY26,
sum(decode(d.dayno,27,NVL(S.QTY,0),0)) DAY27,
sum(decode(d.dayno,28,NVL(S.QTY,0),0)) DAY28,
sum(decode(d.dayno,29,NVL(S.QTY,0),0)) DAY29,
sum(decode(d.dayno,30,NVL(S.QTY,0),0)) DAY30,
sum(decode(d.dayno,31,NVL(S.QTY,0),0)) DAY31,
sum(S.qty) TU
FROM
(select nvl(sales_detail.qty+sales_detail.bonus,0) as qty,
sales_detail.item_code AS ITEM_CODE,
stock_reg.descr AS descr,
s_date as sale_date,stock_reg.GRAND_TOTAL AS GRAND_TOTAL FROM
SALES_DETAIL,SALES_HEADER,STOCK_REG
WHERE SALES_DETAIL.S_ID = SALES_HEADER.S_ID AND
SALES_DETAIL.ITEM_CODE = STOCK_REG.ITEM_CODE(+) AND
STOCK_REG.COMCODE='C1'
UNION all
select -1*nvl(sales_detailR.qty+sales_detailR.bonus,0) as qty,
sales_detailR.item_code AS ITEM_CODE,
stock_reg.descr AS descr,
RETURN_date as sale_date,stock_reg.GRAND_TOTAL AS GRAND_TOTAL FROM
SALES_DETAILR,SALES_HEADERR,STOCK_REG
WHERE SALES_DETAILR.SR_ID = SALES_HEADERR.SR_ID AND
SALES_DETAILR.ITEM_CODE = STOCK_REG.ITEM_CODE(+) AND
STOCK_REG.COMCODE='C1') S,
(select level as dayno
from dual
connect by level <= 31) d
where d.dayno = to_char(s.sALE_date, 'DD') AND TO_DATE(S.SALE_DATE) BETWEEN '&FROMDATE' AND '&TODATE'
GROUP BY S.ITEM_CODE,S.DESCR,S.GRAND_TOTALwell my query running successfully just the quesion was that i wanted to bring some changes in the query to retrieve the complete record which has no transaction in sales
for exmple
if i write the quey
select dept.deptno,sum(sal) from emp,dept
where dept.deptno = emp.deptno
group by dept.deptno
the recult comes as
DEPTNO SUM(SAL)
10 8750
20 10875
30 9400
though there is another deptno which is deptno no 40
have no sal
and when i use this query
select dept.deptno,sum(sal) from emp,dept
where dept.deptno = emp.deptno(+)
group by dept.deptno
it shows the dept no 40 also
DEPTNO SUM(SAL)
10 8750
20 10875
30 9400
40
so to get this i posted query which was to long to understand easily.
i accept that i sholud post short query to make other understand
so check out this
select STOCK_rEG.item_code AS ITEM_CODE,SUM(qty) as qty
FROM
SALES_DETAILR,SALES_HEADERR,STOCK_REG
WHERE SALES_DETAILR.SR_ID = SALES_HEADERR.SR_ID AND
SALES_DETAILR.STOCKCODE = STOCK_REG.STOCKCODE
AND RETURN_DATE = '01-APR-08'
GROUP BY STOCK_rEG.item_code
ORDER BY TO_NUMBER(ITEM_CODE) ASC
when i execute this query i get the following result
ITEM_CODE QTY
84 2
102 3
108 3
116 6
166 3
170 3
thoug there is other items are aalso available in stock which transaction
yet not been done or not been sold out/
so when i use the outer join i get the same result
select STOCK_rEG.item_code AS ITEM_CODE,SUM(qty) as qty
FROM
SALES_DETAILR,SALES_HEADERR,STOCK_REG
WHERE SALES_DETAILR.SR_ID = SALES_HEADERR.SR_ID AND
SALES_DETAILR.STOCKCODE(+) = STOCK_REG.STOCKCODE
AND RETURN_DATE = '01-APR-08'
GROUP BY STOCK_rEG.item_code
ORDER BY TO_NUMBER(ITEM_CODE) ASC
ITEM_CODE QTY
84 2
102 3
108 3
116 6
166 3
170 3
hope i tried to make u understand on better way -
DSO Lookup - Cannot get correct result
Hi
I have a requirement to create new report that will contain the following PO quantity , PO quantity received in time and PO quantity received late.
I have identified in 2LIS_02_SCL DS that ProcessKey 001 is for PO quantity and ProcessKey 002 is the goods receipts (BWMNG-> CPQUAOU) while (DBWMNG-> CPDEOGQUOU) is for delta change
The data is now in DSO but I would like to have them in Cube
Steps I have taken
- I have Created new Inobject ZPO_QUANTITY and ZPO_QTY_REC
- Added this infoobjects to the cube
I wrote this code in END ROUTINE when loading from DSO to the cube but I am not getting the required result. Instead I get same values e.g 2 for all PO document numbers even though the values are different.
u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026
DATA: rp TYPE tys_tg_1.
LOOP AT RESULT_PACKAGE INTO rp.
SELECT SINGLE CPQUAOU FROM /BIC/APMMSC00 into rp-/BIC/ ZPO_QUANTITY
WHERE PROCESSKEY = 001.
MODIFY RESULT_PACKAGE FROM rp.
ENDLOOP.
u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026
Please whats wrong with my code and I can I achieve the result
thanksHello Vamsi and Mansi,
thanks alot guys. Unfortunately I don't get correct result for all PO Documents
I am trying to extract only CPQUAOU from DSO but not getting same in Infocube
This is the code
DOC_NUM PROCESSKEY PSTNG_DATE MATERIAL SCL_DELDAT COMPL_DEL CPQUAOU
4500000118 001 00.00.0000 000000000500024490 18.05.2009 12,000
4500000118 002 18.05.2009 000000000500024490 18.05.2009 10,000
4500000119 011 00.00.0000 000000000400000023 18.05.2009 100,000
4500000120 001 00.00.0000 000000000500024490 18.05.2009 20,000
4500000120 002 21.05.2009 000000000500024490 18.05.2009 X 20,000
4500000121 002 18.05.2009 000000000500024490 18.05.2009 X 10,000
4500000121 001 00.00.0000 000000000500024490 18.05.2009 10,000
4500000122 001 00.00.0000 000000000500024490 18.05.2009 4,000
4500000122 002 24.05.2009 000000000500024490 18.05.2009 X 4,000
4500000123 011 00.00.0000 000000000400000026 18.05.2009 4,000
4500000124 001 00.00.0000 000000000500024490 18.05.2009 5,000
4500000124 002 25.05.2009 000000000500024490 18.05.2009 X 5,000
4500000125 011 00.00.0000 000000000400000026 18.05.2009 2,000
DATA: rp TYPE tys_tg_1.
LOOP AT RESULT_PACKAGE INTO rp.
SELECT SINGLE CPQUAOU FROM /BIC/AMOMMSC00 into rp-/BIC/ZPO_QTY
WHERE DOC_NUM = rp-DOC_NUM AND PROCESSKEY = 001.
*Deriving PO Quantity received in time based on posting date, planned
*delivery date and delivery completed flag
SELECT SINGLE CPQUAOU FROM /BIC/AMOMMSC00 into rp-/BIC/ZPO_REC
WHERE DOC_NUM = rp-DOC_NUM AND PROCESSKEY = 002 AND COMPL_DEL = 'X' AND
PSTNG_DATE <= rp-SCL_DELDAT.
if sy-subrc = 0.
MODIFY RESULT_PACKAGE FROM rp.
endif.
clear rp.
ENDLOOP.
Thanks alot -
How to get correct result in MD04
Hi Gurus,
For a packaging material under this process order A01, it requires 10000 EA.
Goods issue to order done in 3 batches,
first posting with 2 batches:
ABatch - 2372.00
BBatch - 7610.00
2nd posting one batch:
BBatch - 50.00
When run MD04, it still show that this process order need 7,578.000 qty, and when i checked the material under this
process order A01, qty withdrawn only 2422.00.
But in MCRX, the total withdrawal qty is 10032.00, which is correct.
Why it didn't capture the qty withdrawn of 7610.00 for this BBatch?
What should I do in order to get the correct result in MD04?
Please kindly help.
Many thanks in advance.Dear Dhaval & Prasobh,
The actual scenario is that we have this Process order A01, for this packaging material component it required 10000, but the problem is the stock available is by batch:
ABatch - 2372.00
BBatch - 8000.00
We are practicing FIFO, therefore, during MIGO> Goods Issue> Order, after enter the order A01, all the component under this order will be populated. Since there's only one line populated for this packaging material component under this order, as we need to have 2 batches in order to cater for all the 10000 qty, we have to right click>add new line in the MIGO screen, and enter the material/qty/batch and order number (under account assignment tab) manually, then only post at once (one material document generated)
How should we do if this is not the correct way of doing?
Or we need to post those planned GI, then only do another posting for those remaining qty that yet to be posted?
Or we need to manually set the Final Issue everytime after the above done, before we TECO the process order?
Dear Dhaval,
Yes, I have checked in the List documented goods movement, the goods movement indicator for this manual entered line is "2".
I will try your suggestion to manually activate the check box for "Fls"- Final Issue field in change process order.
Thanks & Regards,
Sue -
How to write a query to get this result?
I have four tables. how to get the result meet the following condition?
1,select all from USERACC_FOR_DOM_REP table.
2,then take out(filter out) the username from EXCEPTION_ACC table where EXCEPTION_ACC.username=USERACC_FOR_DOM_REP.username and
EXCEPTION_ACC.TARGET_DB=USERACC_FOR_DOM_REP.TARGET_DB
3, then take out(filter out) the username from MAX_USER_LOGIN table where MAX_USER_LOGIN.username=USERACC_FOR_DOM_REP.username and
MAX_USER_LOGIN.TARGET_DB=USERACC_FOR_DOM_REP.TARGET_DB and MAX_USER_LOGIN.LAST_LOGIN < sysdate -90).
4, then take out(filter out) the username from MYTABLE table where MYTABLE.username=USERACC_FOR_DOM_REP.username and
MYTABLE.TARGET_DB=USERACC_FOR_DOM_REP.TARGET_DB
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
SQL> desc USERACC_FOR_DOM_REP
Name Null? Type
USERNAME NOT NULL VARCHAR2(30)
ACCOUNT_STATUS NOT NULL VARCHAR2(32)
TARGET_DB VARCHAR2(9)
SQL> desc EXCEPTION_ACC
Name Null? Type
USERNAME NOT NULL VARCHAR2(30)
TARGET_DB VARCHAR2(15)
SQL> desc MAX_USER_LOGIN
Name Null? Type
USERNAME NOT NULL VARCHAR2(30)
TARGET_DB VARCHAR2(9)
LAST_LOGIN DATE
INSERT_DATE DATE
SQL> desc MYTABLE
Name Null? Type
USERNAME VARCHAR2(20)
TARGET_DB VARCHAR2(20)sorry if i didn't make this clear.
here is the problem. i have three tables. like below. i also give some sample data
USERS, USER_MAX_LOGIN, EXCEPTION_USER
USERS table has all the user information for each user in each database.
USER_MAX_LOGIN has those users who logged in within 1 year (we keep 1 year audit data)
EXCEPTION_USER has user which should be excluded from the report.
My report need to find all users in all databases who has not logged in for more than 90 days.
USERS
username target_db profile
u1 d1 user
u2 d1 user
u3 d2 user
u1 d2 user
u2 d2 user
u3 d1 user
USER_MAX_LOGIN
username target_db last_login_date
u1 d1 02-Jan-12
u3 d2 06-Aug-11
u1 d2 06-Aug-11
u2 d2 06-Sep-11
EXCEPTION_USER
username target_db
u2 d1
THIS IS THE REPORT I NEED TO BE LOOK LIKE.
username target_db last_login profile
u3 d2 06-Aug-11 user
u1 d2 06-Aug-11 user
u2 d2 06-Sep-11 user
u3 d1 UNKNOWN user <<----- the unknown means we don't know when the user logged in last time. the user_max_login table does not have its information. -
Log application query not showing correct results
Hi,
We are running Dataguard (DG) in our production environment. EBS 11.5.10.2 and DB 10.2.0.4.
Every morning we run the following query on both primary and standby to confirm that the logs are being transported and applied to the standby:
select sequence#,applied,to_char(first_time,'mm/dd/yy hh24:mi:ss') first from v$archived_log order by first_time;
Once the logs are transported and applied, a response of 'Yes' is returned for each log generated. We have noticed within the last week that when we run the query on primary, 'No' is being returned, but on standby, 'Yes' is returned. I have confirmed that standby is reflecting the correct results. I've tried restarting the DG service (alter database recover managed standby....) in an attempt to have primary 'refresh' itself but that didn't work.
Does anyone have any idea why primary keeps returning 'No' to the query, and how we can get it to reflect to correct results?
Thanks,
Lia.Hi Werner,
Thanks for your response. Given what you're saying I find that a little strange since prior to this, the query would return a value of 'YES' on the primary. Actually, to be exact, on the primary, each log would should up twice. One would show 'NO' and the other 'YES'- the second indicating transporting and shipping was successful.
This is how the results were before:
SEQUENCE APP FIRST
+154623 NO 04/07/09 08:03:22+
+154623 YES 04/07/09 08:03:22+
+154624 NO 04/07/09 08:05:27+
+154624 YES 04/07/09 08:05:27+
This is how the results are now:
SEQUENCE APP FIRST
+154754 NO 04/22/09 07:22:22+
+154754 NO 04/22/09 07:22:22+
+154755 NO 04/22/09 07:25:27+
+154755 NO 04/22/09 07:25:27+
I'm not doubting that what you're saying is correct, it just adds an element of confusion for me...
Lia. -
How to check query is getting reused after changing parametr cursor_sharing
Hello,
Oracle Version: 11g
OS Version: Windows 2003 64Bit
How to find if a particular query is getting reused after change in a cursor_sharing parameter from EXACT to SIMILAR.
Which set of Views/DD's should i query go get the relevant details.
Thanks in advance.
-Vijay.SQL> desc v$sqlarea
Name Null? Type
SQL_TEXT VARCHAR2(1000)
SQL_FULLTEXT CLOB
SQL_ID VARCHAR2(13)
SHARABLE_MEM NUMBER
PERSISTENT_MEM NUMBER
RUNTIME_MEM NUMBER
SORTS NUMBER
VERSION_COUNT NUMBER
LOADED_VERSIONS NUMBER
OPEN_VERSIONS NUMBER
USERS_OPENING NUMBER
FETCHES NUMBER
EXECUTIONS NUMBER
PX_SERVERS_EXECUTIONS NUMBER
END_OF_FETCH_COUNT NUMBER
USERS_EXECUTING NUMBER
LOADS NUMBER
FIRST_LOAD_TIME VARCHAR2(19)
INVALIDATIONS NUMBER
PARSE_CALLS NUMBER
DISK_READS NUMBER
DIRECT_WRITES NUMBER
BUFFER_GETS NUMBER
APPLICATION_WAIT_TIME NUMBER
CONCURRENCY_WAIT_TIME NUMBER
CLUSTER_WAIT_TIME NUMBER
USER_IO_WAIT_TIME NUMBER
PLSQL_EXEC_TIME NUMBER
JAVA_EXEC_TIME NUMBER
ROWS_PROCESSED NUMBER
COMMAND_TYPE NUMBER
OPTIMIZER_MODE VARCHAR2(10)
OPTIMIZER_COST NUMBER
OPTIMIZER_ENV RAW(797)
OPTIMIZER_ENV_HASH_VALUE NUMBER
PARSING_USER_ID NUMBER
PARSING_SCHEMA_ID NUMBER
PARSING_SCHEMA_NAME VARCHAR2(30)
KEPT_VERSIONS NUMBER
ADDRESS RAW(4)
HASH_VALUE NUMBER
OLD_HASH_VALUE NUMBER
PLAN_HASH_VALUE NUMBER
MODULE VARCHAR2(64)
MODULE_HASH NUMBER
ACTION VARCHAR2(64)
ACTION_HASH NUMBER
SERIALIZABLE_ABORTS NUMBER
OUTLINE_CATEGORY VARCHAR2(64)
CPU_TIME NUMBER
ELAPSED_TIME NUMBER
OUTLINE_SID VARCHAR2(40)
LAST_ACTIVE_CHILD_ADDRESS RAW(4)
REMOTE VARCHAR2(1)
OBJECT_STATUS VARCHAR2(19)
LITERAL_HASH_VALUE NUMBER
LAST_LOAD_TIME DATE
IS_OBSOLETE VARCHAR2(1)
CHILD_LATCH NUMBER
SQL_PROFILE VARCHAR2(64)
PROGRAM_ID NUMBER
PROGRAM_LINE# NUMBER
EXACT_MATCHING_SIGNATURE NUMBER
FORCE_MATCHING_SIGNATURE NUMBER
LAST_ACTIVE_TIME DATE
BIND_DATA RAW(2000) -
MI 7.1: Query to get correct child objects for a parent
I have this problem for both PDA and Laptop apps.
We have created a Data object with Customer as parent and Email and addresses as child to it. Customer will have basic customer info like his name, nationality etc. email and address will have zero or more emails and addresses of that customer.
In my application I have written a query to fetch all customers, display it in a table and upon selection of one customer I will fetch the customer id which is the key and will fire one more query with customer id as input which will fetch all his addresses and display it in another table.
Now look at this scenario: I create a new customer. Then I go on and create a new address for the same customer. The address will also have foreign key customer id as zero. Now I go on and create one more new customer. Now when I select any of there customers their id is zero (since i havent syncd). Hence my second query would fetch the same newly created address for both the customers since both of them have customer id as zero. Now there is a option for adding join in query in PDA app. I added the join like address.psynckey = customer.synckeyMMW in my second query to fetch addresses apart from filter address.customerid := custid where custid is input parameter. In laptop also I clicked on add join condition by relation button which added to existing condition AND (address.psynckey = customer.synckeyMMW). Now even after this it is not working correctly i.e. only the relevant childs for a parent record should come. Plz help.Hi,
well, I have a problem in understanding.... If I create an item locally on the device - it immediately has a SyncKEy - this is not empty! Furthermore when I select on the item, I have the Top item as select criteria - aswell at the create process. I need the TOP item to create a child item.
Do you have a chance to look into any SAP standard app to get an idea how they do it? The ITEMMANAGER should handle the requested create,delete,modify,select handling for TOp to child items - I think there is the issue.
Regards,
Oliver -
Need SQL query to get the result.
Region
Month
Trx Type
Resolution Summary
AMERICAS
May-13
Adjustments
Correct
EMEA
May-13
Adjustments
Incorrect
AMERICAS
May-13
Credit Memo
Incorrect
EMEA
May-13
Invoice
Correct
AMERICAS
May-13
Credit Memo
Correct
OFD
May-13
Adjustments
Correct
AMERICAS
May-13
Invoice
Incorrect
LAD
May-13
Adjustments
Correct
LAD
May-13
Adjustments
Correct
OFD
May-13
Adjustments
Correct
Above is my Table and find below the required result.Similarly for other regions as well. Can anyone help me with the SQL Query?
Region
Resolution Summary
Adjustment
Credit Memo
Invoice
Grand Total
AMERICAS
Correct
1
1
2
Incorrect
0
1
1
2Like this?
SQL> select * from transaction_audit;
REGION MTH TRX_TYPE RESOLUTIO
AMERICAS may-13 ADJUSTMENTS CORRECT
EMEA may-13 ADJUSTMENTS INCORRECT
AMERICAS may-13 CREDIT MEMO INCORRECT
EMEA may-13 INVOICE CORRECT
AMERICAS may-13 CREDIT MEMO CORRECT
OFD may-13 ADJUSTMENTS CORRECT
AMERICAS may-13 INVOICE INCORRECT
LAD may-13 ADJUSTMENTS CORRECT
LAD may-13 ADJUSTMENTS CORRECT
OFD may-13 ADJUSTMENTS CORRECT
10 rows selected.
SQL> select region
2 , resolution_summary
3 , count(decode(trx_type, 'ADJUSTMENTS', trx_type)) adjustments
4 , count(decode(trx_type, 'CREDIT MEMO', trx_type)) credit_memo
5 , count(decode(trx_type, 'INVOICE' , trx_type)) invoice
6 from transaction_audit
7 group
8 by region
9 , resolution_summary
10 order
11 by region
12 , resolution_summary
13 /
REGION RESOLUTIO ADJUSTMENTS CREDIT_MEMO INVOICE
AMERICAS CORRECT 1 1 0
AMERICAS INCORRECT 0 1 1
EMEA CORRECT 0 0 1
EMEA INCORRECT 1 0 0
LAD CORRECT 2 0 0
OFD CORRECT 2 0 0
6 rows selected.
SQL> -
How to execute query to store the result in the target table column ?
Hi
Source: Oracle
Target: Oracle
ODI: 11g
I have an interface which loads the data from source table to target. Some of the columns in the target tables are automatically mapped with source table. Some of the column remain un-mapped. Those who remain un-mapped, I want to load the values in that column by executing an query. So can anybody tell me where I should mention that query whose result would become the value of the specific column.
-Thanks,
ShrinivasActually I select the column from the target table then in the Property Inspector-->Mapping properties-->Implementation
tab I have written the query which retrieve the value for that column. Is the right place to write the query? How can do this ?
-Shrinivas -
I am looking for only column compare for making my target table same as source table.
My query:
select case when column_name_s is null and column_name_t is not null
then 'alter table GRADE_CONVERSION drop ' || column_name_t || ';'
when column_name_s is not null and column_name_t is null
then 'alter table GRADE_CONVERSION add ' || column_name_s || ' ' || data_type_s ||';'
else 'alter table GRADE_CONVERSION modify ' || column_name_t || ' ' || data_type_t ||';'
end alterations
from (select s.column_name column_name_s,t.column_name column_name_t,
s.data_type data_type_s,t.data_type data_type_t
from (select column_id,column_name,data_type
from all_tab_cols@database
where owner = 'erhan'
and table_name = 'GRADE_CONVERSION'
) s
full outer join
(select column_id,column_name,data_type
from all_tab_cols@database
where owner = 'sarigul'
and table_name = 'GRADE_CONVERSION'
) t
on s.column_name = t.column_name
Tables:
Target table: GRADE_CONVERSION table in sarigul@database
LETTER_GRADE
VARCHAR2(2)
GRADE_POINT
NUMBER(3,2)
MAX_GRADE
NUMBER(3)
MIN_GRADE
NUMBER(3)
Source table: GRADE_CONVERSION table in erhan@database
LETTER_GRADE
VARCHAR2(2)
GRADE_POINT
NUMBER(3,2)
MAX_GRADE
NUMBER(3)
MIN_GRADE
NUMBER(3)
CREATED_BY
VARCHAR2(30)
CREATED_DATE
DATE
MODIFIED_BY
VARCHAR2(30)
MODIFIED_DATE
DATE
want to see the result similar to this *(please ignore the column names here this is just a plain exemple:)
Alter table Target_table modify BOOK_ID Varchar2 (4);
Alter table Target_table add ISBN_10 Varchar2(13), null;
Alter table Target_table drop TITLE;I am looking for only column compare for making my target table same as source table.
My query:
select case when column_name_s is null and column_name_t is not null
then 'alter table GRADE_CONVERSION drop ' || column_name_t || ';'
when column_name_s is not null and column_name_t is null
then 'alter table GRADE_CONVERSION add ' || column_name_s || ' ' || data_type_s ||';'
else 'alter table GRADE_CONVERSION modify ' || column_name_t || ' ' || data_type_t ||';'
end alterations
from (select s.column_name column_name_s,t.column_name column_name_t,
s.data_type data_type_s,t.data_type data_type_t
from (select column_id,column_name,data_type
from all_tab_cols@database
where owner = 'erhan'
and table_name = 'GRADE_CONVERSION'
) s
full outer join
(select column_id,column_name,data_type
from all_tab_cols@database
where owner = 'sarigul'
and table_name = 'GRADE_CONVERSION'
) t
on s.column_name = t.column_name
Tables:
Target table: GRADE_CONVERSION table in sarigul@database
LETTER_GRADE
VARCHAR2(2)
GRADE_POINT
NUMBER(3,2)
MAX_GRADE
NUMBER(3)
MIN_GRADE
NUMBER(3)
Source table: GRADE_CONVERSION table in erhan@database
LETTER_GRADE
VARCHAR2(2)
GRADE_POINT
NUMBER(3,2)
MAX_GRADE
NUMBER(3)
MIN_GRADE
NUMBER(3)
CREATED_BY
VARCHAR2(30)
CREATED_DATE
DATE
MODIFIED_BY
VARCHAR2(30)
MODIFIED_DATE
DATE
want to see the result similar to this *(please ignore the column names here this is just a plain exemple:)
Alter table Target_table modify BOOK_ID Varchar2 (4);
Alter table Target_table add ISBN_10 Varchar2(13), null;
Alter table Target_table drop TITLE; -
Query not retrieving correct result set
I have a query that doesn't seem to be executing its where clause. I used getQuery to check it and ran it in SQL Navigator where it works fine. The same query doesn't work correctly when executed in the OA Framework. Any ideas?
Thanks.Mbolton,
Try asking on the OA Framework Forum.
Best regards,
John "Ask it on the OA Framework Forum" Stegeman -
SQL Query Not Returning Correct Results
I am trying to pull all records that are set for mailing and
are from every state except for Nebraska and some counties in Iowa.
It isn't pulling correctly. Any help would be greatly appreciated.
SELECT HS_SATCode.School, HS_SATCode.Add1, HS_SATCode.City,
HS_SATCode.State, HS_SATCode.[Zip Code], HS_SATCode.county,
HS_SATCode.mail_list
FROM HS_SATCode
WHERE (((HS_SATCode.State)<>'NE') AND
((HS_SATCode.mail_list)=1)) OR (((HS_SATCode.State)='IA') AND
((HS_SATCode.county)<>'Adair' And
(HS_SATCode.county)<>'adams' And
(HS_SATCode.county)<>'audubon' And
(HS_SATCode.county)<>'buena vista' And
(HS_SATCode.county)<>'calhoun' And
(HS_SATCode.county)<>'carroll' And
(HS_SATCode.county)<>'cass' And
(HS_SATCode.county)<>'cherokee' And
(HS_SATCode.county)<>'clay' And
(HS_SATCode.county)<>'crawford' And
(HS_SATCode.county)<>'dickinson' And
(HS_SATCode.county)<>'fremont' And
(HS_SATCode.county)<>'greene' And
(HS_SATCode.county)<>'guthrie' And
(HS_SATCode.county)<>'harrison' And
(HS_SATCode.county)<>'ida' And
(HS_SATCode.county)<>'lyon' And
(HS_SATCode.county)<>'mills' And
(HS_SATCode.county)<>'monona' And
(HS_SATCode.county)<>'montgomery' And
(HS_SATCode.county)<>'o''brien' And
(HS_SATCode.county)<>'osceola' And
(HS_SATCode.county)<>'page' And
(HS_SATCode.county)<>'pottawattamie' And
(HS_SATCode.county)<>'plymouth' And
(HS_SATCode.county)<>'ringold' And
(HS_SATCode.county)<>'sac' And
(HS_SATCode.county)<>'shelby' And
(HS_SATCode.county)<>'sioux' And
(HS_SATCode.county)<>'tayland' And
(HS_SATCode.county)<>'union' And
(HS_SATCode.county)<>'woodbury') AND
((HS_SATCode.mail_list)=1))
ORDER BY HS_SATCode.mail_list, HS_SATCode.State,
HS_SATCode.countyWow, that's a lotta brackets. And most of them are
unnecessary. Let's reduce it a bit.
WHERE
HS_SATCode.State)<>'NE' AND HS_SATCode.mail_list =1
OR (HS_SATCode.State='IA' AND
HS_SATCode.county<>'Adair' )
Can you see how this will send mail to Nebraska? -
Search-Mailbox Search Query not returning correct results.
Hi,
I'd appreciate some assistance with the search and delete I'm trying to I'm run.
I'm using the following command to find messages with a certain message class received before 01/01/14 in a mailbox.
Get-Mailbox xxxxxxxxxxxxxxx | Search-Mailbox -SearchQuery '(Received:< 01/01/14) AND ("IPM.Note.Worksite.Ems.Filed")' -EstimateResultOnly | select displayname, success, resultitemscount,Resultitemssize
When I first ran the command it returned 130,000 items, I ran it again with a -DeleteContent switch, all the items were successfully removed from the mailbox, great! However, when I look in the mailbox I can see ~1000 items with the message class in the command
and dated 2013 or earlier, they meet the search criteria so I don't understand why when I run the command again it returns 0 items.
Help!Hello,
Based on your description, your cmdlet is ok.
When you run the cmdlet with a -DeleteContent switch, the messages are not delete permanently. please try to run the cmdlet with a -DeleteContent switch and -Force switch to check the result.
Besides, please use get-mailboxstatistics | fl cmdlet to check information about mailbox.
Cara Chen
TechNet Community Support -
IPTObjectManager.Query not returning correct result (Java)
Hi,
I am having a problem with the IPTObjectManager.Query method. The code is given below. The issue I am having is, that when I search for a community in a specific folder not results are returned. However if I search in all folders (using -1 as the second parameter to the method) it returns multiple communities including the one I need. Anyone else had the same issue with this??
// THIS CODE WORKS AND RETURN MULTIPLE COMMUNITIES
// THE hotelCode VARIABLE IS A STRING VARIABLE CONTAINING A VALUE
// WHICH IS THE COMMUNITY NAME.
// Create a ObjectManager object
IPTObjectManager objectManager = session.GetObjectManagers(ObjectClass.Community.toInteger());
// define the query based on the passed string
Object[][] vQueryFilter = {
new Object[]{new Integer(PT_PROPIDS.PT_PROPID_NAME)},
new Object[]{new Integer(PT_FILTEROPS.PT_FILTEROP_CONTAINS)},
new Object[]{hotelCode}};
// Run the query and return results
IPTQueryResult ptQueryResult = objectManager.Query(
PT_PROPIDS.PT_PROPID_ALL, -1, PT_PROPIDS.PT_PROPID_NAME, 0, -1, vQueryFilter);
// THIS CODE DOES NOT WORK. I AM PASSING IS THE FOLDER ID OF THE
// FOLDER WHICH CONTAINS THE COMMUNITY
// Create a ObjectManager object
IPTObjectManager objectManager = session.GetObjectManagers(ObjectClass.Community.toInteger());
// define the query based on the passed string
Object[][] vQueryFilter = {
new Object[]{new Integer(PT_PROPIDS.PT_PROPID_NAME)},
new Object[]{new Integer(PT_FILTEROPS.PT_FILTEROP_CONTAINS)},
new Object[]{hotelCode}};
// Run the query and return results
IPTQueryResult ptQueryResult = objectManager.Query(
PT_PROPIDS.PT_PROPID_ALL, 303, PT_PROPIDS.PT_PROPID_NAME, 0, -1, vQueryFilter);I don't know about G6, however in version 5 there does not appear an easy way of doing it. I guess the "easiest" way would be to query sub-folders first, build and array of their ids, and then query for communities in those folders. This is using server API. Something like this (.NET):
publicvoidGetFolderCommunities(intfolderId){ IPTAdminFolder folder =this.session.GetAdminCatalog().OpenAdminFolder(folderId, false); IPTQueryResult qr =folder.QuerySubfolders(PT_PROPIDS.PT_PROPID_ALL, [b]1, null, 0, -1, newobject[][] { newobject[] { PT_PROPIDS.PT_PROPID_FOLDER_FOLDERTYPE }, newobject[] { PT_FILTEROPS.PT_FILTEROP_EQ } , newobject[] { PT_ADMIN_FOLDER_TYPES.PT_ADMIN_FOLDER_TYPE_COMMUNITYFOLDER } } ); int[] folderIds =newint[qr.RowCount()]; Console.WriteLine("------ sub-folders for communities -------"); for(inti =0; i <qr.RowCount(); i++) { intobjectId =qr.ItemAsInt(i, PT_PROPIDS.PT_PROPID_OBJECTID); stringobjectName =qr.ItemAsString(i, PT_PROPIDS.PT_PROPID_NAME); intparentFolderId =qr.ItemAsInt(i, PT_PROPIDS.PT_PROPID_FOLDER_PARENTFOLDERID); folderIds[i] =objectId; Console.WriteLine("{0}: {1}; parent: {2}", objectId, objectName, parentFolderId); } qr =this.session.GetCommunities().Query( PT_PROPIDS.PT_PROPID_ALL, -1, (object) null, 0, -1, newobject[][] { newobject[] { PT_PROPIDS.PT_PROPID_FOLDERID }, newobject[] { PT_FILTEROPS.PT_FILTEROP_IN } , newobject[] { folderIds } } ); Console.WriteLine("------ communities from sub-folders -------"); for(inti =0; i <qr.RowCount(); i++) { intobjectId =qr.ItemAsInt(i, PT_PROPIDS.PT_PROPID_OBJECTID); stringobjectName =qr.ItemAsString(i, PT_PROPIDS.PT_PROPID_NAME); int parentFolderId =qr.ItemAsInt(i, PT_PROPIDS.PT_PROPID_FOLDERID); Console.WriteLine("{0}: {1}; folder: {2}", objectId, objectName, parentFolderId); }}
Or you could use EDK RPC search. Again, in .NET:
publicvoidSearchForCommunities(intfolderId){ IPortalSearchRequest searchRequest =this.ptSession.GetSearchFactory().CreatePortalSearchRequest(); searchRequest.SetObjectTypesToSearch(newObjectClass[] { ObjectClass.Community }); searchRequest.SetDocFoldersToSearch(newint[] {}, true); searchRequest.SetAdminFoldersToSearch(newint[] { folderId}, true); searchRequest.SetResultsCount(0, 100); searchRequest.SetResultsOrderBy(PortalField.OBJECT_ID); searchRequest.SetFieldsToReturn(newPlumtreeField[] {}); searchRequest.SetQuery("*"); ISearchResponse searchResponse =searchRequest.Execute(); intreturnedMatches =searchResponse.GetReturnedCount(); ISearchResultSet resultSet =searchResponse.GetResultSet(); IEnumerator enumerator =resultSet.GetResults(); while(enumerator.MoveNext()) { ISearchResult result =(ISearchResult) enumerator.Current; Console.WriteLine( result.GetFieldAsInt(PortalField.OBJECT_ID) +": "+ result.GetFieldAsString(PlumtreeField.NAME) ); }}
Ruslan.
Maybe you are looking for
-
Error activating DataStore Object
Hi I have created a DSO and put in some key fields and data fields. During activatation, I encountered the following errors. Pls help ! Internal error occurred when writing.. Error while saving change log for DataStore Object.. Error during creation
-
CS6 Premiere Pro generic project icons issue
I installed the new Cloud version of Premiere Pro through my monthly account. I can open projects from Premiere Pro but if I try to open a project file from a folder, the icon is one of those generic icons. I've tried using the Open with...and then
-
What monitors are compatible for an IdeaCentre K230 4GU?
-
When I publish a SWF/HTML5 module with Captivate 8 and try to run it using IE9 - I get the following error "The content you are viewing is not supported in the current Document Mode" - anyone know why?
-
Catalog backup hangs at 8% calculating size (Photoshop elements 10)
I am trying to back up my catalog (+30,000 pics and video's ) to an external drive (full back up). The program starts calculating the size and then hangs at 8%. The catalog was on another computer before and I moved it by making a backup (successfull