Yet another query help request
Imagine the following statement
INSERT table2
SELECT TO_CHAR(col1,'YYYY-WW'), col2, col3, AVG(col4) FROM table1
WHERE TO_CHAR(table1.col1,'YYYY-WW') != TO_CHAR(SYSDATE,'YYYY-WW')
AND (TO_CHAR(table1.col1,'YYYY-WW'), col2)
NOT IN (SELECT col1, col2 FROM table2)
GROUP BY TO_CHAR(col1,'YYYY-WW'), col2, col3;I want to group by calendarweek and calculate an average value. My problem is the corresponding "cleanup" script. I want to create a query which deletes these rows, which are older than ... three years. All I've got for that task is the VARCHAR2-field formatted like "2006-32".
If I want to run a direct comparison like
DELETE FROM table2 WHERE SYSDATE - to_date(col1,'YYYY-WW') > 1095; I get an ORA-01820 error. :-( I'm trying to get a grip on this problem for two days now! Can someone please help me. desparate
what i mean is:
if executed today:
2003-31 will be deleted as we can see it greater than 3 that is,3years
2003-32 wont be deleted as its less than or equal to 3 years old
SQL> select (TO_CHAR(SYSDATE,'YYYY')-(TO_CHAR('2003'))) + (to_char(sysdate,'ww')-(31))/12 from dual;
(TO_CHAR(SYSDATE,'YYYY')-(TO_CHAR('2003')))+(TO_CHAR(SYSDATE,'WW')-(31))/12
3.08333333
SQL> select (TO_CHAR(SYSDATE,'YYYY')-(TO_CHAR('2003'))) + (to_char(sysdate,'ww')-(32))/12 from dual;
(TO_CHAR(SYSDATE,'YYYY')-(TO_CHAR('2003')))+(TO_CHAR(SYSDATE,'WW')-(32))/12
3
SQL> select to_char(sysdate,'ww') from dual;
TO
32
Similar Messages
-
Another query help needed...
I have a tale as follows:
-- INSERTING into TABLE_EXPORT
Insert into TABLE_EXPORT (ACCOUNT_ID,TRANSACTION_AMOUNT,TRANSACTION_TYPE,DRAWEE_ACCOUNT_ID,BENEFICIARY_ACCOUNT_ID) values ('112010026758',6000,'Withdrawal','112010026758',null);
Insert into TABLE_EXPORT (ACCOUNT_ID,TRANSACTION_AMOUNT,TRANSACTION_TYPE,DRAWEE_ACCOUNT_ID,BENEFICIARY_ACCOUNT_ID) values ('112010026758',21664,'Deposit','147010001002','112010026758');
Insert into TABLE_EXPORT (ACCOUNT_ID,TRANSACTION_AMOUNT,TRANSACTION_TYPE,DRAWEE_ACCOUNT_ID,BENEFICIARY_ACCOUNT_ID) values ('112010026758',23000,'Withdrawal','112010026758','147010001000');
Insert into TABLE_EXPORT (ACCOUNT_ID,TRANSACTION_AMOUNT,TRANSACTION_TYPE,DRAWEE_ACCOUNT_ID,BENEFICIARY_ACCOUNT_ID) values ('112010026758',5000,'Withdrawal','112010026758','147010001000');
Insert into TABLE_EXPORT (ACCOUNT_ID,TRANSACTION_AMOUNT,TRANSACTION_TYPE,DRAWEE_ACCOUNT_ID,BENEFICIARY_ACCOUNT_ID) values ('112010026758',15000,'Deposit',null,'112010026758');I need to get the Counterparties and the number of txns with the counterparty and the amount transacted with the counterparties. Here counterparty is decided based on the transaction type i.e., if transaction_type is 'Deposit' then the counterparty is Drawee_Account_id. If transaction_type is 'Withdrawal' then the counterparty is Beneficiary_Account_id.
So in this data for the Account_id 112010026758, there are 2 counterparties - 147010001000 and 147010001002.
I am able to get the count of counterparties and the count of transactions with the counterparty using the following query
Select Account_id,
count(decode(Beneficiary_Account_id,Account_id,Drawee_Account_id,Beneficiary_Account_id)) NoofTransactions,
count(distinct(decode(Beneficiary_Account_id,Account_id,Drawee_Account_id,Beneficiary_Account_id))) Counterparties
from ENTTEST.TABLE_EXPORT
where Account_id = '112010026758'
group by Account_idBut how do i find the sum of transaction amount of the transactions with the counterparty. i.e., for the data above, number of transactions involved with the counterparties is 3 and the sum is 49664.. How can i get that sum??
Can anybody please help me with the query for getting this result...Please.. I am struck at this point..Does this answer your question?
SQL > WITH TABLE_EXPORT AS
2 (
3 SELECT '112010026758' AS ACCOUNT_ID, 6000 AS TRANSACTION_AMOUNT, 'Withdrawal' AS TRANSACTION_TYPE, '112010026758' AS DRAWEE_ACCOUNT_ID, null AS BENEFICI
ARY_ACCOUNT_ID FROM DUAL UNION ALL
4 SELECT '112010026758' AS ACCOUNT_ID, 21664 AS TRANSACTION_AMOUNT, 'Deposit' AS TRANSACTION_TYPE, '147010001002' AS DRAWEE_ACCOUNT_ID, '112010026758' AS
BENEFICIARY_ACCOUNT_ID FROM DUAL UNION ALL
5 SELECT '112010026758' AS ACCOUNT_ID, 23000 AS TRANSACTION_AMOUNT, 'Withdrawal' AS TRANSACTION_TYPE, '112010026758' AS DRAWEE_ACCOUNT_ID, '147010001002'
AS BENEFICIARY_ACCOUNT_ID FROM DUAL UNION ALL
6 SELECT '112010026758' AS ACCOUNT_ID, 5000 AS TRANSACTION_AMOUNT, 'Withdrawal' AS TRANSACTION_TYPE, '112010026758' AS DRAWEE_ACCOUNT_ID, '147010001002' A
S BENEFICIARY_ACCOUNT_ID FROM DUAL UNION ALL
7 SELECT '112010026758' AS ACCOUNT_ID, 15000 AS TRANSACTION_AMOUNT, 'Deposit' AS TRANSACTION_TYPE, null AS DRAWEE_ACCOUNT_ID, '112010026758' AS BENEFICIAR
Y_ACCOUNT_ID FROM DUAL
8 )
9 SELECT ACCOUNT_ID,SUM(TRANSACTION_AMOUNT)
10 FROM TABLE_EXPORT
11 WHERE DRAWEE_ACCOUNT_ID IS NOT NULL
12 AND BENEFICIARY_ACCOUNT_ID IS NOT NULL
13 GROUP BY ACCOUNT_ID
14 /
ACCOUNT_ID SUM(TRANSACTION_AMOUNT)
112010026758 49664This is a modified version of your query:
SQL > WITH TABLE_EXPORT AS
2 (
3 SELECT '112010026758' AS ACCOUNT_ID, 6000 AS TRANSACTION_AMOUNT, 'Withdrawal' AS TRANSACTION_TYPE, '112010026758' AS DRAWEE_ACCOUNT_ID, null AS BENEFICI
ARY_ACCOUNT_ID FROM DUAL UNION ALL
4 SELECT '112010026758' AS ACCOUNT_ID, 21664 AS TRANSACTION_AMOUNT, 'Deposit' AS TRANSACTION_TYPE, '147010001002' AS DRAWEE_ACCOUNT_ID, '112010026758' AS
BENEFICIARY_ACCOUNT_ID FROM DUAL UNION ALL
5 SELECT '112010026758' AS ACCOUNT_ID, 23000 AS TRANSACTION_AMOUNT, 'Withdrawal' AS TRANSACTION_TYPE, '112010026758' AS DRAWEE_ACCOUNT_ID, '147010001002'
AS BENEFICIARY_ACCOUNT_ID FROM DUAL UNION ALL
6 SELECT '112010026758' AS ACCOUNT_ID, 5000 AS TRANSACTION_AMOUNT, 'Withdrawal' AS TRANSACTION_TYPE, '112010026758' AS DRAWEE_ACCOUNT_ID, '147010001002' A
S BENEFICIARY_ACCOUNT_ID FROM DUAL UNION ALL
7 SELECT '112010026758' AS ACCOUNT_ID, 15000 AS TRANSACTION_AMOUNT, 'Deposit' AS TRANSACTION_TYPE, null AS DRAWEE_ACCOUNT_ID, '112010026758' AS BENEFICIAR
Y_ACCOUNT_ID FROM DUAL
8 )
9 SELECT Account_id,
10 COUNT(DECODE(Beneficiary_Account_id,Account_id,Drawee_Account_id,Beneficiary_Account_id)) NoofTransactions,
11 COUNT(DISTINCT(DECODE(Beneficiary_Account_id,Account_id,Drawee_Account_id,Beneficiary_Account_id))) Counterparties,
12 SUM(CASE WHEN BENEFICIARY_ACCOUNT_ID IS NOT NULL AND DRAWEE_ACCOUNT_ID IS NOT NULL THEN TRANSACTION_AMOUNT ELSE NULL END) AS TRANSACTION_AMOUNT
13 FROM TABLE_EXPORT
14 WHERE Account_id = '112010026758'
15 GROUP BY Account_id
16 /
ACCOUNT_ID NOOFTRANSACTIONS COUNTERPARTIES TRANSACTION_AMOUNT
112010026758 3 1 49664Hope this helps! -
I believe I have a problem when opening up my documents in finder. where upon I can view all my folders but with yet another Documents folder within this group, if I then click on this second Documents folder yet again a repeat of the do'cs folder appears. I have tried to merge the Documents folders into one but after a morning and a few hours later having completed the merge when I reopened the folders the problem was still there. Help.
SandraReset the PRAM
Reinstall the operating system from the dvd (you will not loose your data) -
My iPhone will not turn on after a yet another blue screen of death. Please help!
As mentioned above, my phone will not turn on after a yet another blue screen of death. All of a sudden it turned off, and it wouldn't turn on for quite some time, even after I plugged it in the charger. It wasn't long after the screen turned on, but it only displayed a bright black. I decided to turn it on and off a few times. Nothing worked.
I have also tried to call the phone from another one. It was as if the phone was simply off.Hello ZarinaUrum,
The article linked below details a number of troubleshooting steps that can help restore functionality to your iPhone.
iOS: Not responding or does not turn on
http://support.apple.com/en-us/TS3281
Cheers,
Allen -
Yet another grey folder thread, help!
Sorry for yet another grey folder thread, but here goes:
Today, earlier, installed Firefox update, along with some addon updates for that program. Quit Firefox and attempt to relaunch, relaunch fails. Reset computer, thinking that will do the trick, I now have grey folder with question mark.
Resolve attempts: reset pram = fail; apple care cd = will not launch/fail; disk utility from original install disks = fail; cannot get repair of disk or permissions to work, continually get error about "failing on exit"; safe mode launch = fail
So, I've done everything, and I've come to conclusion that I am f***, and my HDD is fried (but I hope I am wrong).
So, dear gurus, my question(s)
A) Is my HDD salvageable at all? is there some trick to getting the AppleCare cd to work? Anything?!?!
if not, then B) How can I recover my documents/music/pictures? Long story short, there are several things on there that never had a chance to make my back up schedule, and I desperately want to keep them. Any way to make/copy a disk image to save the docs/imgs, or Firewire them to an external hdd? Do I need to consider a professional HDD rescue?Looks like a mechanical failure, and Apple won't cover the replacement due to a drop it sustained a year or two ago (the power cable was in, and it fell on the connection point, denting that in, Apple states there is a critical board their and that it would be $950 Tier 3 repair which I can't afford). So I'm going to try a Firewire Migration and a few other things and see if that works. If not, oh well. Thanks everyone for the ideas!
-
Is this yet another problem with 7.5 or is it just me . . .
Upgrade seemed to be fine, at first . . . now I keep getting distortion on songs. It seems to be quite random and just because a song has been distorted when I've listened to it once doesn't mean it will be when I listen to it again! It's driving me insane. Is this yet another bug or have I done something wrong (apart from upgrading to 7.5).
Hi Emlou,
If you have a Windows based operating system such as XP -
It seems to me that you are suffering what I am having the same problem with - the program takes up to much of your computer's processing usage. If you go into your task manager and watch performance as ITunes runs - you will see how much of the total computer usage it is taking at any given moment - that's why your songs are distorted, slowing, garbled, etc - the usage on mine spikes from 11% - 93% AT ANY GIVEN MINUTE! I have no idea why, but I have found that by going to your "Control Panel" and clicking on Quicktime you can adjust audio output to help. Click the audio tab, click Safe Mode Wavout only (checkbox) / Then adjust the "Rate" to 96kHz / Then adjust the "Size" to 16 bit. Close that and shut down and restart Itunes - it might help a little for you.
Maybe someone out there can help us find out why we are suffering with all the CPU usage trouble and how to adjust that spiking.
Thanks!
Paul -
How to use one query results in another query
hi,
in help.sap I have founded that using variable type replacement path I can use one query results in another query. It is wrote there that I have to choose query name results I want to get in variable definition but I do not know where.
How I can do this?
Result I want to get is:
In one query I have material prices in another material quantities. I want to calculate inventory value (price * quantity). Moreover prices are on plant level, quantities on storage type level. Plant is atribute of storage type.
Can I do this?
Regards,
AndrzejHi Andrzej,
please check out this thread: Set parameters values depending on other parameters
I had a discussion about query results as input for another query in there.
For creating a workbook, just click on the save button after you ran your query in the bex.
Siggi
Message was edited by: Siegfried Szameitat -
Problems displaying PDF files in browser - Help requested
The scenario is that I visit a website that has information available via a link that normally would open a PDF document in a browser window. The sort of document, that once open, if I clicked 'File-save as' in the browser would immediately save as a PDF file. In the current situation I click on the link and all I get that opens is a screen full of random characters from top to bottom. I have tried right click 'file save as' on the link that would open the PDF in the browser, but all it wants to save is a .PNG file, i.e. http://echa.europa.eu/echa-styled-theme/images/doc_lang/en.png - which is what I get from right click 'properties' on that link which should open the PDF in the brawser - normally I would see a .PDF file described. I therefore can't even download the file to open as a PDF direct from a stored location on my own PC - all it seems to see is the graphics format - this probably why when the browser goes to open the PDF file I get the random characters, i.e. the application is doing its best to translate what it does see. I would be grateful for some advice. Pertinant information follows:
1. It happens across more websites than just one example that I've quoted.
2. It happens on my desktop only - I don't have the problem on 4 other portable computers, including ones running the same O/S
3. Desktop is running Windows Home Pro, all updates executed, running the latest version of Acrobat reader with all updates executed - I tried yet another uninstall, reboot, new download, reinstall, reboot etc. yesterday. Desktop is HP Pavillion with 12GB RAM
4. I get the random character display when running IE9 on the desktop, I have also replicated the problem with other versions of IE installed instead. If I try using Chrome as a browser it goes away and tries and just fails to open the link entirely and reverts to the original page.
5. I've already checked online for similar problems and can confirm that all the Adobe plugins are installed per what seems standard advice I have also checked the internet settings in Adobe Acrobat preferences and all seems fine.
6. Thing like the browsers and Adobe arobat are running as per their standard set-ups with nothing else done to these.
7. Any other PDF files stored on the hard drive of the desktop open in Acrobat reader without problems
8. Acrobat reader version is 11.0.06.70
Any assistance to open the PDF files in the browser and get it working particularly with IE would be great, I am quite IT literate and can try most things. Many thanksModerator
I have no idea how to edit the above message, but apparently it has been rejected. I cannot understand why, I am a regular contributor in many forums and have never suffered the indignity of having had a message rejected before. The message contains an excellent example of the problems I am having in the following link Vacancies
How on earth can I demonstrate the problems I am having without being to post an example - that example has both sorts of links on one page, ones I can open and ones I can't - if anyone with technical knowledge is trying to help me then that is just the sort of page that would be useful to help solve the problem. Rather than the link to the ECHA website in the above posting (which I note was approved). I struggle with your logic in accepting one message and rejecting the other. It is difficult enough as a user to describe a problem in words let alone have the best example of the problem rejected without explanation and no right of appeal on the email that I got telling me. Not happy here! All I am trying to do is to solve the problem I have -
Yet another Mac Book Pro (A1211/2.33 GHz) freeze problem
Hi everyone,
I have yet another freeze mystery, if people fancy having a crack at it.
I had this notebook for about 4 and a half years and it served me well until 2 months ago. It is a 15' MBP from December 2008 (A1211) with a 2.33GHz Core 2 Duo and 2GB of RAM.
Now I constantly get lags or freezes while I am using it.It manifests itself via the beachball and a frozen screen. First, I thought it was the hard drive but I replaced it with a tested new one and I still get the same behaviour. The reason I thought it was the HD is that it seems to freeze often when there was a lot of access to HD or memory. For example, firefox would cause a freeze quite often when it was trying to access the cache or history. I get the same behaviour when trying indexing my music for the genius feature. Often when I close applications, it will halt the system for about 2 minutes.
I think the number of lags also correlates with temperature. I am pretty sure that the notebook's heat diffusion properties has deteriorated strongly over the past year as it seems to be using the fans a lot more extensively. The heatsink seems to get really hot these days as well. So my next step would be checking the thermal paste on the heat sink. Before I am going to do that, I want to consider any remaining options as dismantling the laptop up to the heatsink is a bit of a pain.
My gut feeling would be that it has to do either with the memory or maybe some 'bridge' that transfers the data between HD, GPU, CPU and memory. I am aware that bridge is the wrong word and I am simplifying the architecture of the mainboard too much, but I am sure you get what I mean. The data rate between some of those is inhibited.
The reason why I am saying some is that often the system seems overwhelmed by the amount of commands, just sits there and then resumes executing all of them as it had taken a break. This can be easily seen when streaming video in a web browser. I often get the beach ball and my whole screen freezes, but the movie, or at least the sound, keeps running in the background. After a while it usually resumes and shows the movie at the current playing position. Sometimes it doesn't recover, not even after 30 minutes and I have to switch it off.
I hope I provided enough information for you guys to have a think about this.
Any help in this matter would be gratefully appreciated.Before re-installing the operating system, which might also work, I found this article helpful:
http://macs.about.com/od/usingyourmac/qt/Fix-Spod-How-To-Fix-A-Spinning-Pinwheel -Of-Death.htm
I've followed the directions since they seem to make sense and am waiting for the next Pinwheel of Death. They seem to be saying the same thing you are Chris, but ascribe the problem to 'permissions' which are fixable (gasp) via the OS disc utility. -
This is my first post in this forum regarding query tuning, so my sincere apologies in advance if I have:
1) not included sufficient information,
2) included too much information,
3) not posted to the correct forum
I read through Randolf Geist's web page on instructions to post a query tuning request
and attempted to follow it as closely as possible.
I am attempting to figure out where a view I have constructed can be optimized.
It takes approx. 45 seconds to 1 minute to run; I would like to cut that down to 10 seconds if possible.
The view itself is somewhat complex; I will post the actual code if it will help you help me. Please advise.
I was under the impression that posting the code was not necessary, but if it is, let me know and I will post it.
I have been doing SQL development for a few years, but only recently in Oracle.
I have no experience in looking through the following output and being able to tell where I can improve performance,
so this will be a learning experience for me. Thanks in advance for your help - I appreciate it.
Some additional information - my view is based on tables over which I have no control - it is a third-party application
which I do reporting from. I do have the freedom to create indexes on columns within the tables if necessary.
The statement is simply
SELECT * FROM LLU_V_PRODUCTION_DETAIL_03
which is the name of my view.
here's all the information I've been able to retrieve by following Randolf's instructions:
Oracle version is 10.2.0.1.0 - 64bit
Here are optimizer parameters:
NAME TYPE VALUE
user_dump_dest string C:\ORACLE\PRODUCT\10.2.0\ADMIN
\AXIUMPRODUCTION\UDUMP
NAME TYPE VALUE
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 10.2.0.1
optimizer_index_caching integer 90
optimizer_index_cost_adj integer 20
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
NAME TYPE VALUE
db_file_multiblock_read_count integer 16
NAME TYPE VALUE
db_block_size integer 8192
NAME TYPE VALUE
cursor_sharing string EXACT
SNAME PNAME PVAL1 PVAL2
SYSSTATS_INFO STATUS COMPLETED
SYSSTATS_INFO DSTART 10-29-2005 01:36
SYSSTATS_INFO DSTOP 10-29-2005 01:36
SYSSTATS_INFO FLAGS 1
SYSSTATS_MAIN CPUSPEEDNW 1298.56584
SYSSTATS_MAIN IOSEEKTIM 10
SYSSTATS_MAIN IOTFRSPEED 4096
SYSSTATS_MAIN SREADTIM
SYSSTATS_MAIN MREADTIM
SYSSTATS_MAIN CPUSPEED
SYSSTATS_MAIN MBRC
SYSSTATS_MAIN MAXTHR
SYSSTATS_MAIN SLAVETHR
13 rows selected.Here is the output of EXPLAIN PLAN:
PLAN_TABLE_OUTPUT
Plan hash value: 662813077
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 23M| 53G| | 62330 (2)| 00:12:28 |
| 1 | VIEW | LLU_V_PRODUCTION_DETAIL_03 | 23M| 53G| | 62330 (2)| 00:12:28 |
| 2 | UNION-ALL | | | | | | |
|* 3 | HASH JOIN | | 18M| 5062M| | 1525 (10)| 00:00:19 |
| 4 | VIEW | index$_join$_007 | 1725 | 25875 | | 4 (25)| 00:00:01 |
|* 5 | HASH JOIN | | | | | | |
| 6 | INDEX FAST FULL SCAN | USERS_PRIMARY | 1725 | 25875 | | 1 (0)| 00:00:01 |
| 7 | INDEX FAST FULL SCAN | USERS_PRODUCER | 1725 | 25875 | | 2 (0)| 00:00:01 |
|* 8 | HASH JOIN | | 416K| 105M| | 1399 (2)| 00:00:17 |
| 9 | TABLE ACCESS FULL | PRODUCER | 1396 | 118K| | 24 (0)| 00:00:01 |
|* 10 | HASH JOIN | | 29819 | 5183K| | 1372 (2)| 00:00:17 |
| 11 | TABLE ACCESS FULL | CLASS | 20 | 1660 | | 3 (0)| 00:00:01 |
|* 12 | TABLE ACCESS FULL | QR_PRODUCTION | 149K| 13M| | 1367 (2)| 00:00:17 |
|* 13 | FILTER | | | | | | |
|* 14 | HASH JOIN | | 16M| 5651M| | 32983 (2)| 00:06:36 |
| 15 | VIEW | index$_join$_014 | 1725 | 25875 | | 4 (25)| 00:00:01 |
|* 16 | HASH JOIN | | | | | | |
| 17 | INDEX FAST FULL SCAN | USERS_PRIMARY | 1725 | 25875 | | 1 (0)| 00:00:01 |
| 18 | INDEX FAST FULL SCAN | USERS_PRODUCER | 1725 | 25875 | | 2 (0)| 00:00:01 |
|* 19 | HASH JOIN | | 149K| 49M| | 32874 (1)| 00:06:35 |
| 20 | TABLE ACCESS FULL | CLASS | 20 | 1660 | | 3 (0)| 00:00:01 |
|* 21 | HASH JOIN | | 149K| 37M| | 32870 (1)| 00:06:35 |
| 22 | TABLE ACCESS FULL | PRODUCER | 1396 | 118K| | 24 (0)| 00:00:01 |
|* 23 | HASH JOIN | | 222K| 37M| 12M| 32844 (1)| 00:06:35 |
| 24 | TABLE ACCESS FULL | PATIENT | 188K| 10M| | 6979 (1)| 00:01:24 |
|* 25 | HASH JOIN | | 222K| 24M| | 23860 (2)| 00:04:47 |
|* 26 | TABLE ACCESS FULL | PROCEDUR | 888 | 44400 | | 11 (0)| 00:00:01 |
|* 27 | TABLE ACCESS FULL | TRX | 442K| 28M| | 23845 (2)| 00:04:47 |
|* 28 | TABLE ACCESS FULL | USERS | 1 | 11 | | 55 (0)| 00:00:01 |
| 29 | NESTED LOOPS | | 1 | 473 | | 25798 (1)| 00:05:10 |
| 30 | NESTED LOOPS | | 1 | 413 | | 25797 (1)| 00:05:10 |
| 31 | NESTED LOOPS | | 1 | 398 | | 25796 (1)| 00:05:10 |
| 32 | NESTED LOOPS | | 1 | 390 | | 25795 (1)| 00:05:10 |
|* 33 | HASH JOIN | | 1 | 303 | | 25794 (1)| 00:05:10 |
| 34 | TABLE ACCESS FULL | LLU_EVALUATION_DESCRIPTIONS | 95 | 6175 | | 3 (0)| 00:00:01 |
|* 35 | HASH JOIN | | 4630 | 1076K| | 25791 (1)| 00:05:10 |
|* 36 | HASH JOIN | | 9607 | 1623K| | 23834 (1)| 00:04:47 |
| 37 | MERGE JOIN | | 888 | 91464 | | 13 (8)| 00:00:01 |
| 38 | TABLE ACCESS BY INDEX ROWID | CLASS | 20 | 1660 | | 1 (0)| 00:00:01 |
| 39 | INDEX FULL SCAN | CLASS_PRIMARY | 20 | | | 1 (0)| 00:00:01 |
|* 40 | SORT JOIN | | 888 | 17760 | | 12 (9)| 00:00:01 |
|* 41 | TABLE ACCESS FULL | PROCEDUR | 888 | 17760 | | 11 (0)| 00:00:01 |
|* 42 | TABLE ACCESS FULL | TRX | 19125 | 1307K| | 23820 (1)| 00:04:46 |
|* 43 | TABLE ACCESS FULL | GRADITEM | 655K| 40M| | 1952 (1)| 00:00:24 |
| 44 | TABLE ACCESS BY INDEX ROWID | PRODUCER | 1 | 87 | | 1 (0)| 00:00:01 |
|* 45 | INDEX UNIQUE SCAN | PRODUCER_PRIMARY | 1 | | | 1 (0)| 00:00:01 |
|* 46 | TABLE ACCESS BY INDEX ROWID | GRADING | 1 | 8 | | 1 (0)| 00:00:01 |
|* 47 | INDEX UNIQUE SCAN | GRADING_PRIMARY | 1 | | | 1 (0)| 00:00:01 |
| 48 | TABLE ACCESS BY INDEX ROWID | USERS | 221 | 3315 | | 1 (0)| 00:00:01 |
|* 49 | INDEX RANGE SCAN | USERS_PRODUCER | 1 | | | 1 (0)| 00:00:01 |
| 50 | TABLE ACCESS BY INDEX ROWID | PATIENT | 1 | 60 | | 1 (0)| 00:00:01 |
|* 51 | INDEX UNIQUE SCAN | PATIENT_PRIMARY | 1 | | | 1 (0)| 00:00:01 |
| 52 | TABLE ACCESS BY INDEX ROWID | USERS | 109 | 1635 | | 1 (0)| 00:00:01 |
| 53 | NESTED LOOPS | | 1 | 438 | | 2023 (1)| 00:00:25 |
| 54 | NESTED LOOPS | | 1 | 423 | | 2022 (1)| 00:00:25 |
| 55 | NESTED LOOPS | | 1 | 363 | | 2021 (1)| 00:00:25 |
| 56 | NESTED LOOPS | | 1 | 276 | | 2020 (1)| 00:00:25 |
| 57 | NESTED LOOPS | | 1 | 193 | | 2019 (1)| 00:00:25 |
| 58 | NESTED LOOPS | | 1 | 185 | | 2018 (1)| 00:00:25 |
| 59 | NESTED LOOPS | | 1 | 173 | | 2017 (1)| 00:00:25 |
| 60 | NESTED LOOPS | | 1 | 140 | | 2016 (1)| 00:00:25 |
|* 61 | TABLE ACCESS FULL | GRADITEM | 317 | 23141 | | 1953 (2)| 00:00:24 |
|* 62 | TABLE ACCESS BY INDEX ROWID| TRX | 1 | 67 | | 1 (0)| 00:00:01 |
|* 63 | INDEX UNIQUE SCAN | TRX_PRIMARY | 1 | | | 1 (0)| 00:00:01 |
|* 64 | TABLE ACCESS BY INDEX ROWID | TRX | 1 | 33 | | 1 (0)| 00:00:01 |
|* 65 | INDEX UNIQUE SCAN | TRX_PRIMARY | 1 | | | 1 (0)| 00:00:01 |
|* 66 | TABLE ACCESS BY INDEX ROWID | GRADITEM | 1 | 12 | | 1 (0)| 00:00:01 |
|* 67 | INDEX RANGE SCAN | GRADITEM_ID | 19 | | | 1 (0)| 00:00:01 |
|* 68 | TABLE ACCESS BY INDEX ROWID | GRADING | 1 | 8 | | 1 (0)| 00:00:01 |
|* 69 | INDEX UNIQUE SCAN | GRADING_PRIMARY | 1 | | | 1 (0)| 00:00:01 |
| 70 | TABLE ACCESS BY INDEX ROWID | CLASS | 1 | 83 | | 1 (0)| 00:00:01 |
|* 71 | INDEX UNIQUE SCAN | CLASS_PRIMARY | 1 | | | 1 (0)| 00:00:01 |
| 72 | TABLE ACCESS BY INDEX ROWID | PRODUCER | 1 | 87 | | 1 (0)| 00:00:01 |
|* 73 | INDEX UNIQUE SCAN | PRODUCER_PRIMARY | 1 | | | 1 (0)| 00:00:01 |
| 74 | TABLE ACCESS BY INDEX ROWID | PATIENT | 1 | 60 | | 1 (0)| 00:00:01 |
|* 75 | INDEX UNIQUE SCAN | PATIENT_PRIMARY | 1 | | | 1 (0)| 00:00:01 |
|* 76 | INDEX RANGE SCAN | USERS_PRODUCER | 1 | | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
3 - access("QRP"."ProviderID"="U1"."Producer")
5 - access(ROWID=ROWID)
8 - access(TRIM("QRP"."ProviderID")=TRIM("P"."Producer"))
10 - access(TRIM("QRP"."axiUm_Discipline")=TRIM("CLASS"."Class"))
12 - filter("QRP"."ProviderID" IS NOT NULL AND "QRP"."Location"<'9990' AND "QRP"."ProcedureID"<>185 AND
"QRP"."PatientFirstName"<>'NON-PATIENT' AND ("QRP"."PatientFirstName"<>'TED' OR "QRP"."PatientLastName" NOT LIKE
'CAVENDER%'))
13 - filter( NOT EXISTS (SELECT 0 FROM AXIUM."USERS" "USERS" WHERE "Custom3"='YES' AND LNNVL("User"<>:B1)) OR
TO_CHAR(INTERNAL_FUNCTION("P"."EndDate"),'YYYY')<'2011' OR TRIM(TO_CHAR(INTERNAL_FUNCTION("P"."EndDate"),'YYYY')) IS
NULL OR "TRX"."Procedure"='A0021' OR "TRX"."Procedure"='A0022')
14 - access("TRX"."Producer"="U1"."Producer")
16 - access(ROWID=ROWID)
19 - access("PROC"."Discipline"="CLASS"."Class")
21 - access("TRX"."Producer"="P"."Producer")
23 - access("TRX"."Patient"="PAT"."Patient")
25 - access("TRX"."Procedure"="PROC"."Procedure")
26 - filter("PROC"."Discipline" IS NOT NULL)
27 - filter("TRX"."Deleted"=0 AND "TRX"."Status"='C' AND "TRX"."Procedure" NOT LIKE 'D0149%' AND
"TRX"."Procedure"<>'D5001C')
28 - filter("Custom3"='YES' AND LNNVL("User"<>:B1))
33 - access(TRIM(UPPER("GI"."QuestionText"))=TRIM(UPPER("LLU"."GRADITEM_QuestionText")) AND
TRIM(UPPER("GI"."Text"))=TRIM(UPPER("LLU"."GRADITEM_Text")) AND TRIM("TRX"."Procedure")=TRIM("LLU"."ProcedureCode"))
35 - access("TRX"."Type"="GI"."Type" AND "TRX"."Id"="GI"."Id" AND "TRX"."Treatment"="GI"."Treatment")
36 - access("TRX"."Procedure"="PROC"."Procedure")
40 - access("PROC"."Discipline"="CLASS"."Class")
filter("PROC"."Discipline"="CLASS"."Class")
41 - filter("PROC"."Discipline" IS NOT NULL)
42 - filter("TRX"."Grading"<>0 AND "TRX"."Deleted"=0 AND "TRX"."Status"='C')
43 - filter("GI"."Grading"<>0)
45 - access("TRX"."Producer"="P"."Producer")
46 - filter("G"."Deleted"=0)
47 - access("TRX"."Grading"="G"."Grading")
filter("G"."Grading"<>0 AND "G"."Grading"="GI"."Grading")
49 - access("TRX"."Producer"="U1"."Producer")
51 - access("TRX"."Patient"="PAT"."Patient")
61 - filter("GI"."IsHeading"=3 AND TRIM("GI"."QuestionText")='Comments' AND "GI"."Grading"<>0)
62 - filter("TRX"."Grading"<>0 AND "TRX"."Deleted"=0 AND "TRX"."Status"='C' AND ("TRX"."Procedure"='G1002' OR
"TRX"."Procedure"='G1003'))
63 - access("GI"."Type"="TRX"."Type" AND "GI"."Id"="TRX"."Id" AND "GI"."Treatment"="TRX"."Treatment")
64 - filter("TRX"."Grading"<>0 AND "TRX"."Deleted"=0 AND "TRX"."Status"='C' AND ("TRX"."Procedure"='G1002' OR
"TRX"."Procedure"='G1003') AND "TRX"."Grading"="TRX"."Grading")
65 - access("TRX"."Type"="TRX"."Type" AND "TRX"."Id"="TRX"."Id" AND "TRX"."Treatment"="TRX"."Treatment")
66 - filter("GI"."RelValue"<>0 AND "TRX"."Type"="GI"."Type" AND "TRX"."Treatment"="GI"."Treatment")
67 - access("TRX"."Id"="GI"."Id")
68 - filter("G"."Deleted"=0)
69 - access("TRX"."Grading"="G"."Grading")
filter("G"."Grading"<>0 AND "GI"."Grading"="G"."Grading")
71 - access("TRX"."Discipline"="CLASS"."Class")
73 - access("TRX"."Producer"="P"."Producer")
75 - access("TRX"."Patient"="PAT"."Patient")
76 - access("TRX"."Producer"="U1"."Producer")
138 rows selected.
Elapsed: 00:00:00.62
631015 rows selected.
Elapsed: 00:01:49.13Output from AUTOTRACE (I think)
NOTE: this post was too long for the forum, so I have removed a number of lines in the following output which appeared to be duplicating the above section (EXPLAIN PLAN).
Statistics
2657 recursive calls
0 db block gets
12734113 consistent gets
13499 physical reads
0 redo size
103697740 bytes sent via SQL*Net to client
69744 bytes received via SQL*Net from client
6312 SQL*Net roundtrips to/from client
76 sorts (memory)
0 sorts (disk)
631015 rows processedThe TKPROF output
select * from llu_v_production_detail_03
call count cpu elapsed disk query current rows
Parse 1 0.51 0.51 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 6312 88.09 98.01 13490 12733584 0 631015
total 6314 88.60 98.52 13490 12733584 0 631015
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 57
Rows Row Source Operation
631015 VIEW LLU_V_PRODUCTION_DETAIL_03 (cr=12733584 pr=13490 pw=0 time=92145592 us)
631015 UNION-ALL (cr=12733584 pr=13490 pw=0 time=91514573 us)
125485 HASH JOIN (cr=8099 pr=6396 pw=0 time=1523326 us)
1725 VIEW index$_join$_007 (cr=24 pr=0 pw=0 time=4777 us)
1725 HASH JOIN (cr=24 pr=0 pw=0 time=3051 us)
1725 INDEX FAST FULL SCAN USERS_PRIMARY (cr=7 pr=0 pw=0 time=50 us)(object id 55023)
1725 INDEX FAST FULL SCAN USERS_PRODUCER (cr=17 pr=0 pw=0 time=16 us)(object id 55024)
144513 HASH JOIN (cr=8075 pr=6396 pw=0 time=2326445 us)
1396 TABLE ACCESS FULL PRODUCER (cr=107 pr=0 pw=0 time=29 us)
144513 HASH JOIN (cr=7968 pr=6396 pw=0 time=2035684 us)
20 TABLE ACCESS FULL CLASS (cr=7 pr=0 pw=0 time=71 us)
151043 TABLE ACCESS FULL QR_PRODUCTION (cr=7961 pr=6396 pw=0 time=313553 us)
462685 FILTER (cr=10755862 pr=7094 pw=0 time=58570941 us)
466790 HASH JOIN (cr=145247 pr=7094 pw=0 time=11007301 us)
1725 VIEW index$_join$_014 (cr=24 pr=0 pw=0 time=6817 us)
1725 HASH JOIN (cr=24 pr=0 pw=0 time=5091 us)
1725 INDEX FAST FULL SCAN USERS_PRIMARY (cr=7 pr=0 pw=0 time=35 us)(object id 55023)
1725 INDEX FAST FULL SCAN USERS_PRODUCER (cr=17 pr=0 pw=0 time=19 us)(object id 55024)
485205 HASH JOIN (cr=145223 pr=7094 pw=0 time=10945107 us)
20 TABLE ACCESS FULL CLASS (cr=7 pr=0 pw=0 time=105 us)
507772 HASH JOIN (cr=145216 pr=7094 pw=0 time=11947534 us)
1396 TABLE ACCESS FULL PRODUCER (cr=107 pr=0 pw=0 time=18 us)
507772 HASH JOIN (cr=145109 pr=7094 pw=0 time=10924473 us)
188967 TABLE ACCESS FULL PATIENT (cr=31792 pr=0 pw=0 time=188998 us)
507772 HASH JOIN (cr=113317 pr=7094 pw=0 time=9652037 us)
895 TABLE ACCESS FULL PROCEDUR (cr=46 pr=0 pw=0 time=65 us)
509321 TABLE ACCESS FULL TRX (cr=113271 pr=7094 pw=0 time=5604567 us)
8548 TABLE ACCESS FULL USERS (cr=10610615 pr=0 pw=0 time=39053120 us)
42669 NESTED LOOPS (cr=507317 pr=0 pw=0 time=3686506 us)
42669 NESTED LOOPS (cr=421535 pr=0 pw=0 time=3217140 us)
45269 NESTED LOOPS (cr=301155 pr=0 pw=0 time=2449542 us)
45323 NESTED LOOPS (cr=210131 pr=0 pw=0 time=2134056 us)
45323 HASH JOIN (cr=119056 pr=0 pw=0 time=1635472 us)
95 TABLE ACCESS FULL LLU_EVALUATION_DESCRIPTIONS (cr=7 pr=0 pw=0 time=118 us)
98272 HASH JOIN (cr=119049 pr=0 pw=0 time=1446703 us)
46996 HASH JOIN (cr=109018 pr=0 pw=0 time=944857 us)
786 MERGE JOIN (cr=50 pr=0 pw=0 time=1528 us)
20 TABLE ACCESS BY INDEX ROWID CLASS (cr=4 pr=0 pw=0 time=99 us)
20 INDEX FULL SCAN CLASS_PRIMARY (cr=1 pr=0 pw=0 time=10 us)(object id 53850)
786 SORT JOIN (cr=46 pr=0 pw=0 time=750 us)
895 TABLE ACCESS FULL PROCEDUR (cr=46 pr=0 pw=0 time=18 us)
47196 TABLE ACCESS FULL TRX (cr=108968 pr=0 pw=0 time=805137 us)
696300 TABLE ACCESS FULL GRADITEM (cr=10031 pr=0 pw=0 time=277 us)
45323 TABLE ACCESS BY INDEX ROWID PRODUCER (cr=91075 pr=0 pw=0 time=414937 us)
45323 INDEX UNIQUE SCAN PRODUCER_PRIMARY (cr=45752 pr=0 pw=0 time=198709 us)(object id 54581)
45269 TABLE ACCESS BY INDEX ROWID GRADING (cr=91024 pr=0 pw=0 time=353081 us)
45270 INDEX UNIQUE SCAN GRADING_PRIMARY (cr=45753 pr=0 pw=0 time=173185 us)(object id 54088)
42669 TABLE ACCESS BY INDEX ROWID USERS (cr=120380 pr=0 pw=0 time=703786 us)
42669 INDEX RANGE SCAN USERS_PRODUCER (cr=46127 pr=0 pw=0 time=249186 us)(object id 55024)
42669 TABLE ACCESS BY INDEX ROWID PATIENT (cr=85782 pr=0 pw=0 time=407452 us)
42669 INDEX UNIQUE SCAN PATIENT_PRIMARY (cr=43098 pr=0 pw=0 time=198477 us)(object id 54370)
176 TABLE ACCESS BY INDEX ROWID USERS (cr=49426 pr=0 pw=0 time=1783886 us)
367 NESTED LOOPS (cr=49149 pr=0 pw=0 time=6159428 us)
190 NESTED LOOPS (cr=48953 pr=0 pw=0 time=409391 us)
190 NESTED LOOPS (cr=48569 pr=0 pw=0 time=407105 us)
190 NESTED LOOPS (cr=48185 pr=0 pw=0 time=404820 us)
191 NESTED LOOPS (cr=47991 pr=0 pw=0 time=410291 us)
193 NESTED LOOPS (cr=47603 pr=0 pw=0 time=422507 us)
193 NESTED LOOPS (cr=46979 pr=0 pw=0 time=416890 us)
193 NESTED LOOPS (cr=46396 pr=0 pw=0 time=414374 us)
14285 TABLE ACCESS FULL GRADITEM (cr=9602 pr=0 pw=0 time=85793 us)
193 TABLE ACCESS BY INDEX ROWID TRX (cr=36794 pr=0 pw=0 time=128427 us)
8218 INDEX UNIQUE SCAN TRX_PRIMARY (cr=28576 pr=0 pw=0 time=64353 us)(object id 54930)
193 TABLE ACCESS BY INDEX ROWID TRX (cr=583 pr=0 pw=0 time=2169 us)
193 INDEX UNIQUE SCAN TRX_PRIMARY (cr=390 pr=0 pw=0 time=918 us)(object id 54930)
193 TABLE ACCESS BY INDEX ROWID GRADITEM (cr=624 pr=0 pw=0 time=4840 us)
1547 INDEX RANGE SCAN GRADITEM_ID (cr=395 pr=0 pw=0 time=2910 us)(object id 54093)
191 TABLE ACCESS BY INDEX ROWID GRADING (cr=388 pr=0 pw=0 time=1887 us)
191 INDEX UNIQUE SCAN GRADING_PRIMARY (cr=197 pr=0 pw=0 time=943 us)(object id 54088)
190 TABLE ACCESS BY INDEX ROWID CLASS (cr=194 pr=0 pw=0 time=1306 us)
190 INDEX UNIQUE SCAN CLASS_PRIMARY (cr=4 pr=0 pw=0 time=551 us)(object id 53850)
190 TABLE ACCESS BY INDEX ROWID PRODUCER (cr=384 pr=0 pw=0 time=1617 us)
190 INDEX UNIQUE SCAN PRODUCER_PRIMARY (cr=194 pr=0 pw=0 time=715 us)(object id 54581)
190 TABLE ACCESS BY INDEX ROWID PATIENT (cr=384 pr=0 pw=0 time=1941 us)
190 INDEX UNIQUE SCAN PATIENT_PRIMARY (cr=194 pr=0 pw=0 time=939 us)(object id 54370)
176 INDEX RANGE SCAN USERS_PRODUCER (cr=196 pr=0 pw=0 time=1389 us)(object id 55024)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 6312 0.00 0.00
db file scattered read 1614 0.02 2.08
SQL*Net message from client 6312 0.00 10.11
SQL*Net more data to client 48662 0.00 0.70
db file sequential read 4645 0.02 7.11
latch: shared pool 7 0.00 0.00
latch: cache buffers chains 1 0.00 0.00
********************************************************************************Again, I apologize if this is way more information than is necessary.
All advice/suggestions/assistance will be gratefully accepted.
CarlHi Rob,
Thank you for replying. Here is the view definition . . . it looks pretty convoluted, I know.
I am reporting from a database which I have no control over other than to add indexes where needed.
For reporting purposes, I am needing to create the dataset from a number of different tables; hence all the UNION clauses.
-- CODE FOLLOWS
CREATE OR REPLACE VIEW LLU_V_PRODUCTION_DETAIL_03
AS
SELECT
'QR' AS "Source",
U1."User" AS "UserID",
QRP."ProviderID" AS "ProviderID",
P."LastName" AS "ProviderLastName",
P."FirstName" AS "ProviderFirstName",
TO_CHAR(P."EndDate",'YYYY') AS "GraduationYear",
P."PGroup",
QRP."PatientID",
QRP."ChartNumber",
QRP."PatientLastName",
QRP."PatientFirstName",
QRP."ProcedureID" || '-' || QRP."ProcedureSuffix" AS "Procedure",
QRP."ProcedureDescription",
QRP."Tooth" AS "Site",
QRP."Surface",
QRP."axiUm_Discipline" AS "Discipline",
"CLASS"."Rank" AS "DisciplineSorter",
"CLASS"."Name" AS "DisciplineName",
QRP."Points",
0 AS "Hours",
QRP."ServiceDate",
0 AS "Id",
QRP."UniqueID" AS "Grading",
0 AS "LastSort",
QRP."CategoryID",
'' AS "CPAR comments"
FROM QR_PRODUCTION QRP
INNER JOIN PRODUCER P
ON TRIM(QRP."ProviderID") = TRIM(P."Producer")
INNER JOIN CLASS
ON TRIM(QRP."axiUm_Discipline") = TRIM(CLASS."Class")
INNER JOIN USERS U1
ON QRP."ProviderID" = U1."Producer"
WHERE (QRP."Location" < '9990')
AND (QRP."ProviderID" IS NOT NULL)
AND (QRP."ProcedureID" <> 185)
-- skip the Cavender family - training patients
AND NOT (QRP."PatientLastName" LIKE 'CAVENDER%' AND QRP."PatientFirstName" = 'TED')
AND QRP."PatientFirstName" <> 'NON-PATIENT'
--ORDER BY QRP."ProcedureID"
UNION ALL
SELECT
'axiUm TRX' AS "Source",
U1."User" AS "UserID",
TRX."Producer" AS "ProviderID",
P."LastName",
P."FirstName",
TO_CHAR(P."EndDate",'YYYY') AS "GraduationYear",
P."PGroup",
PAT."Patient",
PAT."Chart",
PAT."Last" AS "PatientLastName",
PAT."First" AS "PatientFirstName",
TRX."Procedure",
PROC."Description",
TRX."Site",
TRX."Surface",
TRIM(PROC."Discipline") AS "Discipline",
"CLASS"."Rank" AS "DisciplineSorter",
"CLASS"."Name",
CASE WHEN
((TRX."Procedure" IN ('A0013','A0019','A0020','A0021','A0023','A0024','A0025','A0026','A0027','A0028','A0029','A0030','O179'))
OR
-- no points are to be awarded for any procedures performed on typodonts
(EXISTS (SELECT 1 FROM PTTYPES PTT WHERE PTT."Patient" = PAT."Patient" and PTT."PatType" = 'TYPO' and PTT."Deleted" = 0)))
AND -- except for the following procedures
(TRX."Procedure" NOT IN ('A0015','A0016','A0018','D0210'))
THEN 0 ELSE PROC."RelValue" END AS "Points",
CASE WHEN TRX."Procedure" IN ('A0013','A0019','A0020','A0021','A0023','A0024','A0025','A0026','A0027','A0028','A0029','A0030','O179')
THEN PROC."RelValue" ELSE 0 END AS "Hours",
TRX."TreatmentDate",
TRX."Id",
TRX."Grading",
-1 AS "LastSort",
-- additional link conditions added and table name changed on 1 July 2009 - cji
SELECT "CategoryID" FROM LLU_CATEGORIES_X_PROCEDURES_03 LLU
WHERE TRX."Procedure" = LLU."ProcedureID"
AND TO_CHAR(P."EndDate",'YYYY') = LLU."GraduationYear"
AND SUBSTR(TRX."Producer",1,1) = LLU."ProviderType"
AND LLU."CategoryID" NOT IN (82)
) AS "CategoryID",
'' AS "CPAR comments"
FROM TRX
INNER JOIN PATIENT PAT
ON TRX."Patient" = PAT."Patient"
INNER JOIN USERS U1
ON TRX."Producer" = U1."Producer"
INNER JOIN PROCEDUR PROC
ON TRX."Procedure" = PROC."Procedure"
INNER JOIN CLASS
ON PROC."Discipline" = CLASS."Class"
INNER JOIN PRODUCER P
ON TRX."Producer" = P."Producer"
WHERE (TRX."Status" = 'C')
AND (TRX."Deleted" = 0)
--AND (TRX."Grading" = 0)
AND (TRX."Procedure" NOT LIKE 'D0149%')
AND (TRX."Procedure" <> 'D5001C')
-- exclude all procedures approved by Peds faculty ONLY FOR CLASS OF 2011 AND LATER
-- EXCEPT FOR the Peds Block code (A0021 and A0022) - always include those
AND NOT
TRX."AppUser" IN (SELECT "User" FROM USERS WHERE "Custom3" = 'YES') -- Peds faculty
AND
TO_CHAR(P."EndDate",'YYYY') >= '2011'
AND
TRIM(TO_CHAR(P."EndDate",'YYYY')) IS NOT NULL
AND
TRX."Procedure" NOT IN ('A0021','A0022')
UNION ALL
SELECT
'axiUm GRADING' AS "Source",
U1."User" AS "UserID",
TRX."Producer" AS "ProviderID",
P."LastName",
P."FirstName",
TO_CHAR(P."EndDate",'YYYY'), -- Graduation year
P."PGroup",
PAT."Patient",
PAT."Chart",
PAT."Last" AS "PatientLastName",
PAT."First" AS "PatientFirstName",
TRX."Procedure",
LLU."Description",
TRX."Site",
TRX."Surface",
TRIM(PROC."Discipline") AS "Discipline",
"CLASS"."Rank" AS "DisciplineSorter",
"CLASS"."Name",
LLU."Points", --LLU_POINTS_FROM_EVALUATIONS(TRX."Procedure", nvl(GI."Text",0)),
0 AS "Hours",
TRX."TreatmentDate",
GI."Id",
GI."Grading",
GI."Row" AS "LastSort",
LLU."CategoryID",
'' AS "CPAR comments"
FROM TRX
INNER JOIN PATIENT PAT
ON TRX."Patient" = PAT."Patient"
INNER JOIN PRODUCER P
ON TRX."Producer" = P."Producer"
INNER JOIN GRADING G
ON TRX."Grading" = G."Grading"
INNER JOIN GRADITEM GI
ON G."Grading" = GI."Grading"
AND TRX."Type" = GI."Type"
AND TRX."Id" = GI."Id"
AND TRX."Treatment" = GI."Treatment"
INNER JOIN PROCEDUR PROC
ON TRX."Procedure" = PROC."Procedure"
INNER JOIN CLASS
ON PROC."Discipline" = CLASS."Class"
INNER JOIN LLU_EVALUATION_DESCRIPTIONS LLU
ON (TRIM(UPPER(GI."QuestionText")) = TRIM(UPPER(LLU."GRADITEM_QuestionText")))
AND (TRIM(UPPER(GI."Text")) = TRIM(UPPER(LLU."GRADITEM_Text")))
AND (TRIM(TRX."Procedure") = TRIM(LLU."ProcedureCode"))
INNER JOIN USERS U1
ON TRX."Producer" = U1."Producer"
WHERE (TRX."Status" = 'C')
AND (TRX."Deleted" = 0)
AND (TRX."Grading" <> 0)
AND (G."Deleted" = 0)
UNION ALL
SELECT 'ClinPtsAdj',
U1."User" AS "UserID",
TRX."Producer",
P."LastName", P."FirstName",
TO_CHAR(P."EndDate",'YYYY'), -- Graduation year
P."PGroup", PAT."Patient", PAT."Chart", PAT."Last", PAT."First",
TRX."Procedure",
'Clinic points adjustment',
'' AS "Site",
'' AS "Surface",
TRIM(TRX."Discipline"),
"CLASS"."Rank",
"CLASS"."Name",
DERIVED."Points",
0 AS "Hours",
GI."Date",
GI."Id",
GI."Grading",
GI."Row",
NULL AS "CategoryID",
TRIM(REPLACE(GI."Note", CHR(13) || CHR(10), ' '))
FROM TRX
INNER JOIN PATIENT PAT
ON (TRX."Patient" = PAT."Patient")
INNER JOIN PRODUCER P
ON (TRX."Producer" = P."Producer")
INNER JOIN CLASS
ON (TRX."Discipline" = CLASS."Class")
INNER JOIN GRADING G
ON (TRX."Grading" = G."Grading")
INNER JOIN GRADITEM GI
ON (GI."Grading" = G."Grading")
AND (GI."Type" = TRX."Type")
AND (GI."Id" = TRX."Id")
AND (GI."Treatment" = TRX."Treatment")
INNER JOIN USERS U1
ON TRX."Producer" = U1."Producer"
INNER JOIN
SELECT TRX."Type", TRX."Id", TRX."Treatment", TRX."Grading",
CASE WHEN TRX."Procedure" = 'G1003' THEN GI."RelValue" * -1 ELSE "RelValue" END AS "Points"
FROM TRX, GRADITEM GI
WHERE (TRX."Type" = GI."Type")
AND (TRX."Id" = GI."Id")
AND (TRX."Treatment" = GI."Treatment")
AND (TRX."Procedure" IN ('G1002','G1003'))
AND (TRX."Status" = 'C')
AND (TRX."Deleted" = 0)
AND (TRX."Grading" <> 0)
AND (GI."RelValue" <> 0)
) DERIVED
ON (TRX."Type" = DERIVED."Type")
AND (TRX."Id" = DERIVED."Id")
AND (TRX."Treatment" = DERIVED."Treatment")
AND (TRX."Grading" = DERIVED."Grading")
WHERE (TRX."Status" = 'C')
AND (TRX."Deleted" = 0)
AND (TRX."Grading" <> 0)
AND (G."Deleted" = 0)
AND (TRX."Procedure" IN ('G1002','G1003'))
AND (GI."IsHeading" = 3)
AND (TRIM(GI."QuestionText") = 'Comments')
--ORDER BY "ProviderID", "DisciplineSorter", "Id", "Grading", "Site", "LastSort";A couple of additional points:
The table USERS already had an index on column "Producer"; I added an index on column "Custom3" but it did not seem to make any difference.
Table USERS has 1,725 rows
Table PRODUCER (aliased as P) has 1,396 rows
Table TRX has 1,443,764 rows.
Any additional information you need I will be glad to provide.
Thanks a bunch; it may not be too late to teach an old dog new tricks.
And thank you all for the kind words about the posting; about the only thing I can do well is follow directions.
Carl -
Can we use Result from another query in Webi using Bex uery universe?
Hi,
Can we use Result from another query filter option in Webi to create a report using a Bex Query universe?
I need to create a report using two universes, one is Bex Query Universe and the other is Orcle universe. I have two queries, one is using Oracle universe; the other using Bex Query universe. I need to pass the Oracle data from the Oracle query to the Bex Query query to get the matched data from SAP Bex query.
I used Result from another query in the query filter panel for the query using Bex query universe. But I got an error saying that 'A filter contains a wrong value. you cannot run this query. (Error: WIS 00007). The data used in the filter on both sides are the same. they are char.
I have tested by using two queries from the same Bex query universe to see if the Result from another query filter option works. And I got the same error.
Has anyone run into the same issue and if this is possible and what should be the solution?
Thanks in advance!
Edited by: BO_Haiyan on Oct 6, 2010 3:47 PMIn that situation:
Create two queries : Oracle and BW query.
@ Report:
As you have to see result set from both the Dataproviders, correct? To achieve thise one must have common dimension objects to merge them at report and use Objects those are coming from both queries to use them in single Table/Report.
Unless you don't use Merge Dimensions, you don't get a chane to use both queries objects in single Table/Report. (It will give tooltip saying: You can't drop here -- Incompatable Objects)
In case, if you don't have common dimensions, change object definitions to Detail objects, for those required.
Hope it helps you.
Thank You!! -
Is it possible to update a query with another query?
I'm trying to update a query with another query (see attached
code). Here's my setup: I've got a table in an Access database in
which I enter a string into a form and update. This string
corresponds to a single record in another table of the same
datasource. The first table has only one record to provide the
second, which has many and will have more. Basically what I'm
wondering is: Is this a valid thing to do in coldfusion? If not
please help with an alterate method. I'm still a novice at
coldfusion.
The overall effect I'm going for is to display the one record
as a featured truck profile on the web site:
www.truckerstoystore.net.
I currently get an error when I try to display the page with the
current query setup.
Check this page to see the error:
www.truckerstoystore.net/currentTOW2.cfm
Help on this issue is very much appreciated.
------------------------------------------------------------------------------------------ -----------------------------------------------------------------------I think this is what you are after
<!--- this query will get all the records from the DB
--->
<cfquery name="cTOW" datasource="tow">
SELECT *
FROM currentTOW
<!--- Do you need to find a particular record in the
database --->
<!--- If so, then you need a 'where' clause in here
--->
</cfquery>
<!-- Loop the cTOW query for each record returned -->
<cfloop query="cTOW">
<!--- For the record returned from the cTOW query you now
need to update the table --->
<!-- Update the table -->
<cfquery name="currentTOW" datasource="tow">
UPDATE Your tblName
SET
Dataname = cTOW.DataValue
</cfquery>
</cfloop>
thats it
PS: I think your original query needs modifying. To return
the exact records that you want to update from the original table.
ie: Primary and foreign key relationship -
Populating variable from another query..
Hi,
I have a requirement whereby I have a variable (for eg. on the Accounting Document Number) in query Q2.The values of this variable have to be derived by executing another query eg. - Q1
So I defined a variable on the infoobject, defined it as based on Q1 and am using that in Q2.
However the issue is I don't want to restrict query Q2 with that variable.. but just want to read the values and then be able to further processing on that variable. However hard as I try it seems that I can only use that variable as Filter in Q2. Any other options I can use.
I tried to use that variable in a structure but it system does not accept it.
Any ideas would be appreciated.
thxHi ATW,
Looks to me, this is a RRI (Report-To-Report Interface) requirement.
Try following options ->
1. RRI
Consider - Q1 is a 'Sender Query' - This will a 'summary level' query and Q2 would be 'Receiving Query' - This will be 'Detailed level' query.
Do Sedning / Receiving setting in the Tcode RSBBS
Execute Q1 -> Right click on any row -> GOTO -> Q2, it will execute second query with the details on for the row you have selected.
2. Pre-Query & Main Query
Here Q1 will be your 'pre-query' which will run for a given date range. (or any other selection criteria), and it will have 'Accounting Document Number' in the 'ROWS'. The output of Q1 will work as a filter to Q2 (the output of the query Q1 will NOT be visible.)
This output then will work as a filter for the second query Q2.
Let me know if this helps.
Regards,
Rashmi -
Result of an SQL query as a Column name of another query
Hi Friends,
Can we use a result of a SQL Query as a column name of another table to retrieve data. If so please help me.
For eg :
I have a table where is store numbers;
select col1 from table1 where col1='5';
and i have another table where .. this value of col is a column name..
select ( select col1 from table1 where col1='5') from table2;
Thanks in advance.Hi,
ORAFLEX wrote:
Hi Friends,
Can we use a result of a SQL Query as a column name of another table to retrieve data. If so please help me.
For eg :
I have a table where is store numbers;
select col1 from table1 where col1='5';
and i have another table where .. this value of col is a column name..
select ( select col1 from table1 where col1='5') from table2;
Thanks in advance.Do you really mean that?
select col1 from table1 where col1='5';That query will always return either '5' or nothing. Whatever you're trying to accomplish with that, you can do with an EXISTS query.
Perhaps you meant to reference two different columns in that query:
select col1 from table1 where col2='5';In that case, sorry, no, you can't do that without resorting to dynamic SQL.
If the same column is used throughout the query (but could change every time you run the query), then the dynamic SQL might be pretty easy. In SQL*Plus, for example, you could use substitution variables, defined in another query at run-time.
If there are only a few possible values that the sub-query could possibly return, and you know what they all are, then you can fake a dynamic query like this:
SELECT CASE ( SELECT col1
FROM table1
WHERE col2 = '5'
WHEN 'BONUS' THEN bonus
WHEN 'COMM' THEN comm
WHEN 'SAL' THEN sal
END AS col1
FROM table2
;Sorry to give such a vague answer, but it's the best I can do with the information I have.
It would help if you posted a little sample data (CREATE TABLE and INSERT statments for both tables), and the results you want to get from that data. If you want to pass a parameter to the query, give the results you want for a couple of different parameters. -
Can I use the result of a query in another query of the same cube?
Hello everybody;
I have the following case. In query "A", I have used in rows a structure, whit a last formula named Total A, in another query "B", I need to used the result of Total A.
Can anybody help me?
Thanks in advanced.
Mariana SerranoHi Mariana,
You can change local structures into reusable structures in any existing query by selecting the structure and, choosing Save as... from the context menu and then entering a technical name and a description in the Save Structure as... dialog box.
You can change reusable structures that you are using in a query into local structures by selecting the structure and choosing Remove Reference from the context menu.
Also go through this link:
http://help.sap.com/saphelp_sem40bw/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm
Best Regards,
DMK
*Assign point if it helps...
Maybe you are looking for
-
Why do I only have photos option to choose from for uploading my resume?
I'm applying for jobs and have Dropbox plus PDF but when it comes to attaching my resume on job sites I only have the option to choose from photos. Why?!!!! Why in the heck do I only have this ONE limited option? I have PDF and Dropbox- how come I
-
I have a 2006 iMac 2.16 GHz, 4GB ram, Intel Core 2 Duo. I am not planning on using plug-ins, I am a beginning artist and Logic Pro seems to have more than what I need. Any help would be greatly appreciated.
-
Why can I receive but not send emails
Why can I receive but not send emails on my i pad?
-
I created a characteristic hierarchy for G/L account Text node 3000002 characteristic nodes 6850411 interval nodes 6850310 - 6850313 If nothing has been posted to the charc
-
Hello - I'm wondering if anyone can help. Im currently developing a tool which filters and aggregates some data. I have the user to be able to select a period for example - 01/01/2010 to 07/10/2010. Then, I want to compare the selected data with the