Query /Function Help
Hi,
I have a requriment,
can any one please help me to get this in sql query or plsql function,
Example:
I have errors messages in database they will in this format
1)AdjCost;sellprice;customerprice;dealerprice......
2)ctrtprice;invamt;invnum;AdjCost
for the above messages i will be having error codes as
AdjCost=AA
Sellprice=SS
CustomerPrice=CC
DealerPrice=DP
ctrtprice=CP
invamt=ia
invnum=in
error codes are hard coded values
for the first error message above i want output in this way
1)AA;SS;CC;DP
for the second error message above i want output in this way
2)CP;ia;in;AA
Can any one please help me getting this done?
Thanks in Advance
p78 wrote:
Hi,
I have a requriment,
can any one please help me to get this in sql query or plsql function,
Example:
I have errors messages in database they will in this format
1)AdjCost;sellprice;customerprice;dealerprice......
2)ctrtprice;invamt;invnum;AdjCost
for the above messages i will be having error codes as
AdjCost=AA
Sellprice=SS
CustomerPrice=CC
DealerPrice=DP
ctrtprice=CP
invamt=ia
invnum=in
error codes are hard coded values
for the first error message above i want output in this way
1)AA;SS;CC;DP
for the second error message above i want output in this way
2)CP;ia;in;AA
Can any one please help me getting this done?
Thanks in AdvanceHow to ask question
SQL and PL/SQL FAQ
Similar Messages
-
Sql query/function problem??
Hi ,
I have problems writing a difficult sql query, please help me
I have a table t in which there are 50000 records
the table has columns like
create table t
(MATCH_ID NUMBER(4) NOT NULL,
TEAM_ID NUMBER(4),
PLAYER_ID NUMBER(4),
RUNS NUMBER(3))
here match_id, player_id and team_id are jointly primary key
SQL> SELECT * FORM T WHERE MATCH_ID < 10
MATCH_ID TEAM_ID PL_ID RUNS
1 2 1228 8
1 2 1203 82
1 2 1316 24
1 1 1150 27
1 1 1278 13
1 1 1243 60
2 1 1278 37
2 1 1291 0
2 1 1243 53
2 2 1228 25
2 2 1285 103
2 2 1316 60
3 2 1228 8
3 2 1285 25
3 2 858 43
3 1 1278 52
3 1 1394 6
3 1 1243 31
4 1 1278 61
4 1 1394 6
4 1 1243 3
4 2 1228 41
4 2 1285 40
4 2 858 5
6 2 1228 20
6 2 1285 100
6 2 1408 0
7 2 1228 15
7 2 1285 34
7 2 1408 44
8 2 1228 0
8 2 1420 31
8 2 1340 66
9 2 1420 19
9 2 1385 28
9 2 1340 0
.....so on upto 50000 records..
the problem is that I want to extract how many times each player_id in each
match exists in the table, prior to that match_id (or current_match_id)
along with that in another column, I also want the sum of 'RUNS' for each
player_id prior to that match_id (or current_match_id)
my disired output is:
MATCH_ID TEAM_ID player_ID RUNS NO_OF_OCCURENCES SUM(RUNS)
BEFORE_THIS_MATCH BEFORE_THIS_MATCH
FOR_THIS_PLAYER_ID FOR_THIS_PLAYER_ID
1 2 1228 8 0 0
1 2 1203 82 0 0
1 2 1316 24 0 0
1 1 1150 27 0 0
1 1 1278 13 0 0
1 1 1243 60 0 0
2 1 1278 37 1 13
2 1 1291 0 0 0
2 1 1243 53 1 60
2 2 1228 25 1 8
2 2 1285 103 0 0
2 2 1316 60 1 24
3 2 1228 8 2 33
3 2 1285 25 1 103
3 2 858 43 0 0
3 1 1278 52 2 50
3 1 1394 6 0 0
3 1 1243 31 2 113
4 1 1278 61 3 102
4 1 1394 6 1 6
4 1 1243 3 3 144
4 2 1228 41 3 41
4 2 1285 40 2 128
4 2 858 5 1 43
6 2 1228 20 4 82
6 2 1285 100 3 168
6 2 1408 0 0 0
7 2 1228 15 5 102
7 2 1285 34 4 268
7 2 1408 44 1 0
8 2 1228 0 6 117
8 2 1420 31 0 0
8 2 1340 66 0 0
9 2 1420 19 1 31
9 2 1385 28 0 0
9 2 1340 0 1 66
as you can see from the above data (5TH COLUMN), i have mentioned the
existance of each player_id in each match prior to the current_match_id
since match_id = 1 is the 1st match in the table so no player_id comes in the
table before match number 1.
In match number 2 , player_id = 1278 was also present in match_id = 1 so
thats why Number_OF_OCCURENCES = 1 for player_id = 1278 in match_id = 2
and so on..
same is the case with 'RUNS' column but here RUNS are the SUM of each
player_id's 'RUNS' before the current match
Note: if some player_id does not exist in the table before the current
match_ID then the query should return zero for that player_id ( as in 4th and
5th columns of no_of_occurances and sum(runs) respectively)
for example: in above data
MATCH_ID TEAM_ID PLayer_ID RUNS NO_OF_OCCURENCES SUM(RUNS)
BEFORE_THIS_MATCH BEFORE_THIS_MATCH
FOR_THIS_PLAYER_ID FOR_THIS_PLAYER_ID
9 2 1385 28 0 0
I hope this will clear my problem
i would be extremely grateful if someone helps me out??
here is sample ddl of the above data
create table t
(MATCH_ID NUMBER(4) NOT NULL,
TEAM_ID NUMBER(4),
PLAYER_ID NUMBER(4),
RUNS NUMBER(3))
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (1, 2, 1228, 8);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (1, 2, 1203, 82);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (1, 2, 1316, 24);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (1, 1, 1150, 27);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (1, 1, 1278, 13);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (1, 1, 1243, 60);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (2, 1, 1278, 37);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (2, 1, 1291, 0);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (2, 1, 1243, 53);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (2, 2, 1228, 25);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (2, 2, 1285, 103);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (2, 2, 1316, 60);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (3, 2, 1228, 8);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (3, 2, 1285, 25);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (3, 2, 858, 43);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (3, 1, 1278, 52);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (3, 1, 1394, 6);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (3, 1, 1243, 31);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (4, 1, 1278, 61);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (4, 1, 1394, 6);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (4, 1, 1243, 3);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (4, 2, 1228, 41);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (4, 2, 1285, 40);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (4, 2, 858, 5);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (6, 2, 1228, 20);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (6, 2, 1285, 100);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (6, 2, 1408, 0);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (7, 2, 1228, 15);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (7, 2, 1285, 34);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (7, 2, 1408, 44);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (8, 2, 1228, 0);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (8, 2, 1420, 31);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (8, 2, 1340, 66);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (9, 2, 1420, 19);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (9, 2, 1385, 28);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (9, 2, 1340, 0);regards
ramis.Ramis,
SQL> select * from tt;
MATCH_ID TEAM_ID PLAYER_ID RUNS
1 2 1228 8
1 2 1203 82
1 2 1316 24
1 1 1150 27
1 1 1278 13
1 1 1243 60
2 1 1278 37
2 1 1291 0
2 1 1243 53
2 2 1228 25
2 2 1285 103
2 2 1316 60
3 2 1228 8
3 2 1285 25
3 2 858 43
3 1 1278 52
3 1 1394 6
3 1 1243 31
4 1 1278 61
4 1 1394 6
4 1 1243 3
4 2 1228 41
4 2 1285 40
4 2 858 5
6 2 1228 20
6 2 1285 100
6 2 1408 0
7 2 1228 15
7 2 1285 34
7 2 1408 44
8 2 1228 0
8 2 1420 31
8 2 1340 66
9 2 1420 19
9 2 1385 28
9 2 1340 0
36 rows selected.
SQL> select tt.match_id,
tt.team_id,
tt.player_id,
tt.runs,
nvl(a.sum_player,0) OCC,
nvl(b.sum_runs,0) SUM_RUNS
from
tt,
(select a.match_id,a.team_id,a.player_id,a.runs,count(*) sum_player
from tt a,
(select match_id,player_id
from tt
group by match_id,player_id) b
where a.match_id>b.match_id
and a.player_id=b.player_id
group by a.match_id,a.team_id,a.player_id,a.runs
) a,
(select a.match_id,a.team_id,a.player_id,a.runs,sum(b.runs) sum_runs
from tt a,
(select match_id,player_id,runs
from tt) b
where a.match_id>b.match_id
and a.player_id=b.player_id
group by a.match_id,a.team_id,a.player_id,a.runs
) b
where tt.match_id=a.match_id(+)
and tt.team_id=a.team_id(+)
and tt.player_id=a.player_id(+)
and tt.match_id=b.match_id(+)
and tt.team_id=b.team_id(+)
and tt.player_id=b.player_id(+)
MATCH_ID TEAM_ID PLAYER_ID RUNS OCC SUM_RUNS
1 1 1150 27 0 0
1 1 1243 60 0 0
1 1 1278 13 0 0
1 2 1203 82 0 0
1 2 1228 8 0 0
1 2 1316 24 0 0
2 1 1243 53 1 60
2 1 1278 37 1 13
2 1 1291 0 0 0
2 2 1228 25 1 8
2 2 1285 103 0 0
2 2 1316 60 1 24
3 1 1243 31 2 113
3 1 1278 52 2 50
3 1 1394 6 0 0
3 2 858 43 0 0
3 2 1228 8 2 33
3 2 1285 25 1 103
4 1 1243 3 3 144
4 1 1278 61 3 102
4 1 1394 6 1 6
4 2 858 5 1 43
4 2 1228 41 3 41
4 2 1285 40 2 128
6 2 1228 20 4 82
6 2 1285 100 3 168
6 2 1408 0 0 0
7 2 1228 15 5 102
7 2 1285 34 4 268
7 2 1408 44 1 0
8 2 1228 0 6 117
8 2 1340 66 0 0
8 2 1420 31 0 0
9 2 1340 0 1 66
9 2 1385 28 0 0
9 2 1420 19 1 31
36 rows selected.
SQL> Is this do you want ?
Nicolas. -
Dear Sir/Mam
I want SQL query, function or SP which converts binary data to image (.jpg format).
I m able to convert image (.jpg format) to varbinary. But not able to convert vice versa.
thanks in advance.Binary data is binary data - "image" is only an intrepretation of binary data. Therefore your question makes little sense in the context of sql server since it does not have any facilities to utilize images. Since you provide no context, I'm
guessing that you are trying to retrieve an image stored in the database in a varbinary column and have your application use it as an image. If so, you should post your question to a forum that is specific to your development environment. -
How to improve the performance of the attached query, Please help
Hi,
How to improve performance of the below query, Please help. also attached explain plan -
SELECT Camp.Id,
rCam.AccountKey,
Camp.Id,
CamBilling.Cpm,
CamBilling.Cpc,
CamBilling.FlatRate,
Camp.CampaignKey,
Camp.AccountKey,
CamBilling.billoncontractedamount,
(SUM(rCam.Impressions) * 0.001 + SUM(rCam.Clickthrus)) AS GR,
rCam.AccountKey as AccountKey
FROM Campaign Camp, rCamSit rCam, CamBilling, Site xSite
WHERE Camp.AccountKey = rCam.AccountKey
AND Camp.AvCampaignKey = rCam.AvCampaignKey
AND Camp.AccountKey = CamBilling.AccountKey
AND Camp.CampaignKey = CamBilling.CampaignKey
AND rCam.AccountKey = xSite.AccountKey
AND rCam.AvSiteKey = xSite.AvSiteKey
AND rCam.RmWhen BETWEEN to_date('01-01-2009', 'DD-MM-YYYY') and
to_date('01-01-2011', 'DD-MM-YYYY')
GROUP By rCam.AccountKey,
Camp.Id,
CamBilling.Cpm,
CamBilling.Cpc,
CamBilling.FlatRate,
Camp.CampaignKey,
Camp.AccountKey,
CamBilling.billoncontractedamount
Explain Plan :-
Description Object_owner Object_name Cost Cardinality Bytes
SELECT STATEMENT, GOAL = ALL_ROWS 14 1 13
SORT AGGREGATE 1 13
VIEW GEMINI_REPORTING 14 1 13
HASH GROUP BY 14 1 103
NESTED LOOPS 13 1 103
HASH JOIN 12 1 85
TABLE ACCESS BY INDEX ROWID GEMINI_REPORTING RCAMSIT 2 4 100
NESTED LOOPS 9 5 325
HASH JOIN 7 1 40
SORT UNIQUE 2 1 18
TABLE ACCESS BY INDEX ROWID GEMINI_PRIMARY SITE 2 1 18
INDEX RANGE SCAN GEMINI_PRIMARY SITE_I0 1 1
TABLE ACCESS FULL GEMINI_PRIMARY SITE 3 27 594
INDEX RANGE SCAN GEMINI_REPORTING RCAMSIT_I 1 1 5
TABLE ACCESS FULL GEMINI_PRIMARY CAMPAIGN 3 127 2540
TABLE ACCESS BY INDEX ROWID GEMINI_PRIMARY CAMBILLING 1 1 18
INDEX UNIQUE SCAN GEMINI_PRIMARY CAMBILLING_U1 0 1Hello,
This has really nothing to do with the Oracle Forms product.
Please, send the SQL or/and PL/SQL questions in the corresponding forums.
Francois -
Hi all, sry for post sql problens in APEX forum, but i realy need help for this...
I´m trying to replace : for , to make a select where in () with more then one value... but the replace function its not work with more then 1 value...
like this
select name from vw_requerente where id_cliente in REPLACE(:P5000_CLIENTE,':',',')in that item has this value: 71:72:73 , but all i get is a ORA: INVALID NUMBER, how can i make a replace function to work with this?
tnks alot and sry my english.He also posted this in the pl/sql forum and received some good advice there:
replace function help
Especially the tom kyte blog portion:
[http://tkyte.blogspot.com/2006/06/varying-in-lists.html]
Thank you,
Tony Miller
Webster, TX -
Can I combine two bex querys by comining query function
Hi expert,
Can I combine two bex querys by comining query function?
Many Thanks,Hi,
Add a combined query function is not possbile by BICS connectivity.This is product limitation.
Regards,
Amit -
How Queues functionality helps in Service Module
Hi,
How Queues functionality helps in Service Module.
how to get the queue details assign to the service call(Technician)
Please Suggest
Regards
VikramSridharan,
How to add technician to a queue.
Employee should be user of SAP?
Please Suggest.
Vikram -
Query functionality in custom menu
Hi,
I have created my custom menu and attached to my form. when i compiled iam not able to see some standard functions like Query functionality. Is there any process to achieve query functionality in custom menu attached to formYou want to have something like an "Execute Query" in your menu. Add a menuitem of type PL/SQL and put the code
DO_KEY('EXECUTE_QUERY');Same procedure would be for other "query-menu"-items -
Cluster bar chart- sql query please help-
Hi,
I am trying to create cluster bar chart and am stumped with this sql query.Any help is appreciated.
Here is my table
city region issue value
c1 north i1 y
c1 north i2 y
c2 north i1 n
c2 north i2 y
c3 south i1 y
c3 south i2 n
c4 east i1 n
c4 east i2 n
The bar chart will have 3 series, north south and east.
And labels will be i1 and i2. value will be number of times this issue was encountered(y) in this region.
How can I get something like this from the above table-
region issue count(yes)
north i1 1
north i2 2
south i1 1
south i2 0
east i1 0
east i2 0
thanksWITH table1 AS
(SELECT 1435177 qte_id, 2 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 5 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 7 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 8 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 12 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 14 seq_no
FROM dual
table2 AS
SELECT 1435177 qte_id, 1 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 2 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 3 seq_no, 0 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 4 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 5 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 7 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 8 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 11 seq_no, 59300 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 12 seq_no, 59300 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 14 seq_no, 59300 cmmt_curr_amt
FROM dual
SELECT qte_id, t2_seq_no, cmmt_curr_amt - cmmt_curr_lag diff
FROM
(SELECT t2.qte_id, t2.seq_no t2_seq_no, t1.seq_no t1_seq_no, cmmt_curr_amt, LAG(cmmt_curr_amt,1,0) OVER (PARTITION BY t2.qte_id ORDER BY t2.seq_no) cmmt_curr_lag
FROM table1 t1, table2 t2
WHERE t2.qte_id = t1.qte_id (+)
AND t2.seq_no = t1.seq_no(+)
ORDER BY 1,2
WHERE t1_seq_no IS NOT NULL
ORDER BY 1,2
QTE_ID T2_SEQ_NO DIFF
1435177 2 0
1435177 5 0
1435177 7 0
1435177 8 0
1435177 12 0
1435177 14 0 -
Query functions and procedures of a user schema
Hai all,
how can i query functions and procedures of user suppose user scott using sqlplus?
i created a function as user scott how can i view my function name?
ThanksHi,
You can Query from dba_objects of user_objects for View,
select owner,object_name,object_type,status from dba_objects where owner='SCOTT';
or
conn scott/pass
select object_name,object_type,status from user_objects;HTH -
2/3/14: I just updated numbers to newest version and found that numbers quits to home screen when I tap the information icon on "function help", it starts to load the "help" then quits. It happens on both my ipad3 & iphone5. I tried restarting the devices but it didn't help.
Try this - Reset the iPad by holding down on the Sleep and Home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons. (This is equivalent to rebooting your computer.) No data/files will be erased. http://support.apple.com/kb/ht1430
iOS 7: Help with how to fix a crashing app on iPhone, iPad (Mini), and iPod Touch
http://teachmeios.com/help-with-how-to-fix-a-crashing-app-on-iphone-ipad-mini-an d-ipod-touch/
Troubleshooting apps purchased from the App Store
http://support.apple.com/kb/TS1702
Delete the app and redownload.
Downloading Past Purchases from the iTunes Store, App Store and iBooks Store
http://support.apple.com/kb/ht2519
Cheers, Tom -
Need PP Functional help for some legacy fields
Hi all,
I am a BW consultant. I need to replicate in SAP-BW some reports that are currently in a legacy system (non SAP). I have identified the functional area for those reports as PP. I need a little functional help from you guys to find out what some fields in the legacy system mean in SAP. Once I know the R/3 fields (and source tables if someone can tell me), I can move forward with mapping those fields into BW objects and the rest of the process.
The reason why I am seeking help from here is, unfortunately our functional team is not available right now and their availability is indefinite. So I just want to keep myself busy till they are back.
Well, here are the fields that I need help for (for now)
The report is for Daily summary of activities at a plant
Work order process
Work order type
Daily Created Bags
Daily Capacity Bags (Bags per Hour Rate* Available Hours)
Daily Count of Work Order Number
Goods issued for work order completion
Goods finished
Please help me identify what R/3 fields (and their tables) correspond to the above legacy fields
Points WILL be assigned for helpful answers
Thank youHi,
Work order process - I assume this is the set of operations for the order - AFVC (table)
Work order type - AUFK - (Field) AUART data needs to be fetched for AUFNR(Work order number)
Daily Created Bags - MSEG - data needs to be fetched for BWART = 101 or 102 and AUFNR(Work order number)
Goods issued for work order completion - MSEG- data needs to be fetched for BWART = 261 and AUFNR(Work order number)
Goods finished - MSEG - data needs to be fetched for BWART = 101 or 102 and AUFNR(Work order number)
Regards,
Prasobh -
Help with Query function on EAI Siebel Adapter
Can anyone help?
I have a workflow that uses the Query method on EAI Siebel Adapter to search for a Contact in Siebel. The Root component is Contact and the Child component is Address.
When I pass in a message that contains Contact data (i.e. LastName='Jones') and Address data (City='Perth') to query on, it returns all Contacts that match the Contact data, and for each of those Contacts if the address data matches it also returns the address.
What I want it to do is only return those Contacts that match both the Contact data 'AND' the address data, not all of the Contacts that match the contact data.
I hope this makes sense.
I've also tried using the searchspec function too, but this does not do what I want it to do either.
Hope you can help.
Thanks,
Carl
Can aHi,
can you create a MVG in Contact which will refer to Business Address & then try to use searchspec argument. I hope it will work for you. -
Using substr function loses index. Query tune help
Hi
when i use substr function in the join condition it loses index and the query is slow. How to fix this problem or tune this query. These are the lines in the query.
and substr(a.invoice_num,1,9) = l.invoice_num
and substr(c.invoice_num,1,9) = mgr_apprv_lst.user_key
and substr(c.invoice_num,1,9) = pbl_apprv_lst.user_key
select
pap.full_name employe_name,
k.SEGMENT1 ||'.' ||k.segment2 Cost_Center,
a.invoice_num Invoice_Number,
b.item_description Line_Item,
b.amount Amount,
cc.trx_id Corporate_Card_Transaction_Id,
cc.transaction_date Date_Charge_Incurred,
cc.posted_date Date_Charge_Posted_To_USBank,
cc.creation_date Date_Posted_To_IExpense,
a.creation_date Expense_Report_Creation_Date,
l.report_submitted_date Expense_Report_Submitted_Date,
mgr_apprv_lst.activity_begin_date Managers_Approval_Begin_Date,
mgr_apprv_lst.activity_end_date Managers_Approval_End_Date,
pbl_apprv_lst.activity_begin_date AP_Approval_Begin_Date,
pbl_apprv_lst.activity_end_date AP_Approval_End_Date,
e.check_date Payment_Date_To_USBank,
e.check_number Payment_Number,
mgr_apprv_lst.activity_result_display_name Managers_Process_Result,
pbl_apprv_lst.activity_result_display_name AP_Process_Result
from
ap_checks_all e,
ap_invoice_payments_all d,
ap_invoices_all c,
ap_expense_report_headers_all a,
ap_credit_card_trxns_all cc,
per_all_people_f pap,
ap_expense_report_headers_all l,
ap_expense_report_lines_all b,
gl_code_combinations k,
(select ias1.user_key,
ias1.activity_result_display_name,
ias1.activity_begin_date,
ias1.activity_end_date
from wf_item_activity_statuses_v ias1,
(select c1.invoice_num
from ap_checks_all e1,
ap_invoice_payments_all d1,
ap_invoices_all c1
where trunc(e1.check_date) between nvl(:From_Date, trunc(e1.check_date))
and nvl(:To_Date, trunc(e1.check_date))
and e1.org_id = 141
and e1.void_date IS null
and d1.check_id = e1.check_id
and c1.invoice_id = d1.invoice_id) inv_lst1
where ias1.item_type = 'APEXP'
and ias1.user_key = inv_lst1.invoice_num
and ias1.activity_name = 'AP_MANAGER_APPROVAL_PROCESS') mgr_apprv_lst,
(select ias2.user_key,
ias2.activity_result_display_name,
ias2.activity_begin_date,
ias2.activity_end_date
from wf_item_activity_statuses_v ias2,
(select c2.invoice_num
from ap_checks_all e2,
ap_invoice_payments_all d2,
ap_invoices_all c2
where trunc(e2.check_date) between nvl(:From_Date, trunc(e2.check_date))
and nvl(:To_Date, trunc(e2.check_date))
and e2.org_id = 141
and e2.void_date IS null
and d2.check_id = e2.check_id
and c2.invoice_id = d2.invoice_id) inv_lst2
where ias2.item_type = 'APEXP'
and ias2.user_key = inv_lst2.invoice_num
and ias2.activity_name = 'AP_PAYABLES_APPROVAL_PROCESS') pbl_apprv_lst
where
trunc(e.check_date) between nvl(:From_Date, trunc(e.check_date))
and nvl(:To_Date, trunc(e.check_date))
and e.org_id = 141
and e.void_date IS null
and d.check_id = e.check_id
and c.invoice_id = d.invoice_id
and a.invoice_num = c.invoice_num
and a.source = 'CREDIT CARD'
and a.employee_id = nvl(:Emp_id,a.employee_id)
and a.report_header_id = b.report_header_id
and cc.trx_id = b.credit_card_trx_id
and pap.person_id = a.employee_id
and pap.effective_start_date <= trunc(sysdate)
and pap.effective_end_date >= trunc(sysdate)
and k.code_combination_id = b.code_combination_id
and k.segment2 between nvl(:From_Cost_Center,k.segment2)
and nvl(:To_Cost_Center,k.segment2)
and substr(a.invoice_num,1,9) = l.invoice_num
and substr(c.invoice_num,1,9) = mgr_apprv_lst.user_key
and substr(c.invoice_num,1,9) = pbl_apprv_lst.user_keyHi
If I understood correctly your logic, and if the columns involved are of type varchar2, you can use the like operator:
and a.invoice_num like l.invoice_num || '%'
and c.invoice_num like mgr_apprv_lst.user_key || '%'
and c.invoice_num like pbl_apprv_lst.user_key || '%'In this case, Oracle will be able to use the indexes. If they are numeric, you need to do something like:
and a.invoice_num between l.invoice_num * 1000000
and l.invoice_num * 1000000 + 999999I hope this makes sense...
Luis -
Function help: Parameter Query
What SQL Function Criteria string replaces [forms]![myForm].[myField]?
I have a function that I want to pass criteria to from a drop down list. I tried using the same Access string in the Function but it does not work.I am not sure I understand the question but if you are looking for moving from MS-ACCESS to SQL Server then this articl should help you:
http://social.technet.microsoft.com/wiki/contents/articles/22731.convert-vba-code-to-transact-sql.aspx
[Personal Site] [Blog] [Facebook]
Maybe you are looking for
-
How to include the hebrew languare in the Oracle Data?
Hi All, I'm using this code in nls_lang value in the registry to include Arabic and English languages in the data: AMERICAN_AMERICA.AR8MSWIN1256 but how to include the hebrew language to be used in the data also Plz? Note: I'm using Oracle DB 10g R2
-
Hey , i have a simple GUI, a button and a text box. When we click the button a file chooser will appear and we are able to select the folder/file we like. My question is, when we click on the button and when the File chooser window appears, i wont it
-
I am getting alerts that my version of Firefox will not be supported much longer but I can't find an upgrade that works on my Mac Mini running MAC OSX 10.4.11. Shall I use a different browser?
-
Gurus, I need to create a inspection lot for a confirmed production,is it possible.I take UD for Production order.Then shift the material to warehouse.Then i find the product is not perfect.I need to create an inspection fo this material,manually.
-
Line issue, please help - cant see my post
https://supportforums.cisco.com/discussion/12486181/line-console-password-and-enable-secret Hi all, not sure why my post is always not showing, please see above.