Simple Query Help Needed
I must not be in the right mode today, because this is giving
me a hard time...
I have a SQL Server database with 250,000 records. Each
record represents a medical visit.
Each record has 25 fields that contain patient diagnosis. A
visit may show one diagnosis, or it may show as many as 25. Any
specific diagnosis (250.00 for example) may appear in a field
called Code1, or a field called Code2.... Code25.
There are a total of about 500 patients that make up the
250,000 visits.
What I need is a report that shows each DISTINCT diagnosis,
and a listing (and count) of people that have been assigned that
diagnosis.
My thought is to first query the table to arrive at the
unique list of diagnosis codes. Then, in a nested loop, query the
database to see who has been assigned that code, and how many
times.
This strikes me as an incredibly database intensive query,
however.
What is teh correct way to do this?
The correct way to do this is to normalize your database.
Rather than having 25 separate colums that essentially
contain the same data (different codes), break that out into a
separate table.
Patient
patientid
Visit
patientid (foreign key referencing Patient)
visitid
Diagnosis
visitid (foreign key referencing visitid in Visit)
diagnosiscode
order (if the 1-25 ordering of diagnosis codes is important)
Once you correct your datamodel, what you're trying to do
becomes simple.
-- get all diagnosis codes
select distinct(diagnosiscode) from diagnosis
-- get a breakdown of diagnosis codes, patients, and counts
for that diagnosis
select diagnosiscode, patient.name, count(diagnosiscode) from
patient left join visit on (patient.patientid =
visit.patientid)
left join diagnosis on (visit.visitid = diagnosis.visitid)
group by diagnosiscode, patient.name
Similar Messages
-
Looks like a simple query but need your help
Hello everyone,
I have a simple problem but I can't get over it. Actually, it looks like a simple problem, but I can't do it. So,it's probably not... Anyone can help me with this?
Imagine the following data:
ALTER SESSION SET NLS_DATE_FORMAT = 'DD/MM/YYYY HH24:MI:SS';
SELECT TRUNC(SYSDATE) - TO_DATE('01/01/11', 'DD/MM/RR') FROM dual; -- 564
DROP TABLE runs;
CREATE TABLE runs
start_date DATE,
end_date DATE
-- generate some random data
INSERT INTO runs(start_date)
SELECT TO_DATE('01/01/11', 'DD/MM/RR') + trunc(dbms_random.value(0,564))
FROM dual
CONNECT BY LEVEL <= 10000;
-- still generating sample data
UPDATE runs
SET end_date = start_date + dbms_random.value(0,20000) / 86400; -- 20000 sec is the max
COMMIT; If you execute the previous "script", you'll end up with a table called RUNS with 10.000 records. Each record contains a start date and an end date which is max 20.000 second after the start date.
What I would like to do is a report based on these data.
I need something like this:
(first week of 2011 started on sunday. So I go back to the last monday of 2010)
WEEK_NUMBER AVG_FOR_MONDAY_BY_WEEK CUMULATIVE_AVERAGE_FOR_MONDAYS
Week 1: 26/12/2010 - 01/01/2011 9999 88888
Week 2: 02/01/2011 - 08/01/2011 1111 22222
....For each week, I would like to have the average duration (which is the difference in seconds between end_date and start_date) by day (monday needs to have its average, tuesday, wednesday...too)
And I also need a cumulative average by week and by days (mondays, tuesdays...). This cumulative average needs to be based on all the preceding rows.
Can anyone help me with this query? I'm using Oracle 10g
ThanksHi,
Something along these lines :
alter session set nls_date_language = "english";
with all_data as (
select to_char(start_date, 'IYYYIW') as wk
, to_char(start_date, 'dy') as dy
, (end_date - start_date)*86400 as duration
from runs
week_data as (
select wk
, round(avg(case when dy = 'mon' then duration end)) as avg_mon
, round(avg(case when dy = 'tue' then duration end)) as avg_tue
, round(avg(case when dy = 'wed' then duration end)) as avg_wed
, round(avg(case when dy = 'thu' then duration end)) as avg_thu
, round(avg(case when dy = 'fri' then duration end)) as avg_fri
, round(avg(case when dy = 'sat' then duration end)) as avg_sat
, round(avg(case when dy = 'sun' then duration end)) as avg_sun
from all_data
group by wk
select wk
, avg_mon
, sum(avg_mon) over(order by wk) as cum_avg_mon
, avg_tue
, sum(avg_tue) over(order by wk) as cum_avg_tue
, avg_wed
, sum(avg_wed) over(order by wk) as cum_avg_wed
, avg_thu
, sum(avg_thu) over(order by wk) as cum_avg_thu
from week_data
order by wk;
WK AVG_MON CUM_AVG_MON AVG_TUE CUM_AVG_TUE AVG_WED CUM_AVG_WED AVG_THU CUM_AVG_THU
201052
201101 9836 9836 8737 8737 9088 9088 12167 12167
201102 7639 17475 10319 19056 7391 16479 8036 20203
201103 8275 25750 8883 27939 8525 25004 11682 31885
201104 7029 32779 10850 38789 7360 32364 7617 39502
201105 10292 43071 11421 50210 11141 43505 9469 48971
201106 11612 54683 9762 59972 11464 54969 9517 58488
201107 8645 63328 10206 70178 10124 65093 11917 70405
201108 11466 74794 11678 81856 10839 75932 9587 79992
201109 8745 83539 6803 88659 8963 84895 9496 89488
201110 10443 93982 8104 96763 10314 95209 10908 100396
201111 8183 102165 9467 106230 11495 106704 12040 112436
201112 8575 110740 9207 115437 10338 117042 9561 121997
201113 10273 121013 6268 121705 11288 128330 12335 134332
201114 10176 131189 8561 130266 10367 138697 7983 142315
201115 10587 141776 12073 142339 8528 147225 12271 154586
201116 9393 151169 10761 153100 7901 155126 10020 164606
201117 11459 162628 9471 162571 10136 165262 8188 172794
201118 11946 174574 9997 172568 9367 174629 10475 183269
201119 12869 187443 9848 182416 7692 182321 9632 192901
201120 9675 197118 7408 189824 11646 193967 9614 202515
201121 10742 207860 10302 200126 9208 203175 7543 210058
201122 8083 215943 8323 208449 10045 213220 9498 219556
201123 11838 227781 8820 217269 8804 222024 10485 230041
201124 8748 236529 12143 229412 9684 231708 8402 238443
201125 11504 248033 10586 239998 10073 241781 9573 248016
201126 7289 255322 14241 254239 10100 251881 11843 259859
201127 10855 266177 9980 264219 10320 262201 11023 270882
201128 11004 277181 9975 274194 11609 273810 8945 279827
201129 10488 287669 9402 283596 11985 285795 9481 289308
201130 7338 295007 8963 292559 11982 297777 8177 297485
201131 9778 304785 10024 302583 10732 308509 10749 308234
201132 10360 315145 12577 315160 8643 317152 10001 318235
201133 9845 324990 10416 325576 9996 327148 10548 328783
201134 9540 334530 8138 333714 9401 336549 9093 337876
201135 7000 341530 9920 343634 10370 346919 10937 348813
201136 11307 352837 8889 352523 12339 359258 8491 357304
201137 11785 364622 9146 361669 9232 368490 11023 368327
201138 7857 372479 6784 368453 8502 376992 12558 380885
201139 9842 382321 10616 379069 10435 387427 7848 388733
201140 10578 392899 9402 388471 8806 396233 9927 398660
201141 6711 399610 13015 401486 9934 406167 10011 408671
201142 10088 409698 10380 411866 7836 414003 9205 417876
201143 8132 417830 11772 423638 10792 424795 10834 428710
201144 9921 427751 7454 431092 9551 434346 10754 439464
201145 13196 440947 11600 442692 11303 445649 10455 449919
201146 12022 452969 8996 451688 10221 455870 12567 462486
201147 8965 461934 10068 461756 10607 466477 13486 475972
201148 9483 471417 9264 471020 9601 476078 8685 484657
201149 11738 483155 9000 480020 10284 486362 11263 495920
201150 10338 493493 10237 490257 10357 496719 10984 506904
201151 10777 504270 11138 501395 10543 507262 9840 516744
201152 9881 514151 10692 512087 11432 518694 10122 526866
201201 11089 525240 8077 520164 12391 531085 9649 536515
201202 9871 535111 8326 528490 9449 540534 10551 547066
201203 10625 545736 11609 540099 9626 550160 5795 552861
201204 8856 554592 9679 549778 10722 560882 11064 563925
201205 9379 563971 9943 559721 8409 569291 11656 575581
201206 10843 574814 10070 569791 12162 581453 10764 586345
201207 8424 583238 8484 578275 8382 589835 8716 595061
201208 11159 594397 10415 588690 11459 601294 11317 606378
201209 11264 605661 8244 596934 9682 610976 10192 616570
201210 11514 617175 9322 606256 9101 620077 10571 627141
201211 9348 626523 7501 613757 12297 632374 11170 638311
201212 10523 637046 7605 621362 10348 642722 10068 648379
201213 10411 647457 11686 633048 10212 652934 9574 657953
201214 9394 656851 10526 643574 8521 661455 9829 667782
201215 8994 665845 12256 655830 8243 669698 10592 678374
201216 11491 677336 10939 666769 12846 682544 9708 688082
201217 9737 687073 9611 676380 7244 689788 10943 699025
201218 9024 696097 11286 687666 10033 699821 10314 709339
201219 9851 705948 9851 697517 9159 708980 9917 719256
201220 7785 713733 10490 708007 8534 717514 8528 727784
201221 11107 724840 8197 716204 8926 726440 10834 738618
201222 8093 732933 11853 728057 11697 738137 10081 748699
201223 9371 742304 10796 738853 11068 749205 9904 758603
201224 10600 752904 8487 747340 10838 760043 8009 766612
201225 11090 763994 9595 756935 10736 770779 9387 775999
201226 8234 772228 12759 769694 9119 779898 8422 784421
201227 9738 781966 9383 779077 8978 788876 11635 796056
201228 11687 793653 10302 789379 9459 798335 10608 806664
201229 9245 802898 11290 800669 798335 806664
82 rows selected -
Hi
I need help in writing a sql query for the data given below
Market Description Revenue
LARGE CORPORATE 0.0
LARGE CORPORATE 0.0
OTHERS 0.0
OTHERS 1.98
LARGE CORPORATE 5.1299999999999999
LARGE CORPORATE 6.8500000000000005
LARGE CORPORATE 10.98
LARGE CORPORATE 16.490000000000002
LARGE CORPORATE 21.129999999999999
LARGE CORPORATE 28.66
LARGE CORPORATE 38.579999999999998
OTHERS 68.420000000000002
OTHERS 87.590000000000003
LARGE CORPORATE 90.040000000000006
LARGE CORPORATE 511.94
LARGE CORPORATE 625.01999999999998
LARGE CORPORATE 662.75999999999999
LARGE CORPORATE 700.68000000000006
LARGE CORPORATE 2898.6799999999998
LARGE CORPORATE 3273.96
OTHERS 3285.4400000000001
LARGE CORPORATE 3580.0799999999999
LARGE CORPORATE 4089.1900000000001
LARGE CORPORATE 4373.5200000000004
LARGE CORPORATE 16207.550000000001
LARGE CORPORATE 19862.740000000002
LARGE CORPORATE 33186.150000000001
LARGE CORPORATE 107642.79000000001
The output of query should be in the following format
Market Description 1st 10%(revenue) 2nd 10%(revenue) 3rd 10%(revenue) 4th 10%(revenue) 5th 10%(revenue) rest 50%(revenue)
Would appreciate any help on this query.Hi,
What does 1st 10%, 2nd 10% etc. mean?
Is it 0-10%, 11-20%, 21-30%....
If so, combination of floor,decode and division should help to
achieve the result.
For example for the followint table,
NAME SALE
SALES_GROUP1 .2
SALES_GROUP1 1
SALES_GROUP1 9
SALES_GROUP2 2.1
SALES_GROUP2 12.2
SALES_GROUP2 19.9
SALES_GROUP3 22.2
write,
select name,decode(floor(sale/10),0,sale,null) "1st10%",
decode(floor(sale/10),1,sale,null)"11to20%",
decode(floor(sale/10),2,sale,null) "21to30%"
from revenue;
I mean, using floor and division, your rounding all values b/w 0 to 10 as 0
Similarly, 11 to 20 has be rounded to 1 etc...then apply decode function it
to achive the result.
I hope this helps.
Regards,
Suresh
8i OCP. -
Query help needed for querybuilder to use with lcm cli
Hi,
I had set up several queries to run with the lcm cli in order to back up personal folders, inboxes, etc. to lcmbiar files to use as backups. I have seen a few posts that are similar, but I have a specific question/concern.
I just recently had to reference one of these back ups only to find it was incomplete. Does the query used by the lcm cli also only pull the first 1000 rows? Is there a way to change this limit somwhere?
Also, since when importing this lcmbiar file for something 'generic' like 'all personal folders', pulls in WAY too much stuff, is there a better way to limit this? I am open to suggestions, but it would almost be better if I could create individual lcmbiar output files on a per user basis. This way, when/if I need to restore someone's personal folder contents, for example, I could find them by username and import just that lcmbiar file, as opposed to all 3000 of our users. I am not quite sure how to accomplish this...
Currently, with my limited windows scripting knowledge, I have set up a bat script to run each morning, that creates a 'runtime' properties file from a template, such that the lcmbiar file gets named uniquely for that day and its content. Then I call the lcm_cli using the proper command. The query within the properties file is currently very straightforward - select * from CI_INFOOBJECTS WHERE SI_ANCESTOR = 18.
To do what I want to do...
1) I'd first need a current list of usernames in a text file, that could be read (?) in and parsed to single out each user (remember we are talking about 3000) - not sure the best way to get this.
2) Then instead of just updating the the lcmbiar file name with a unique name as I do currently, I would also update the query (which would be different altogether): SELECT * from CI_INFOOBJECTS where SI_OWNER = '<username>' AND SI_ANCESTOR = 18.
In theory, that would grab everything owned by that user in their personal folder - right? and write it to its own lcmbiar file to a location I specify.
I just think chunking something like this is more effective and BO has no built in back up capability that already does this. We are on BO 4.0 SP7 right now, move to 4.1 SP4 over the summer.
Any thoughts on this would be much appreciated.
thanks,
MissyJust wanted to pass along that SAP Support pointed me to KBA 1969259 which had some good example queries in it (they were helping me with a concern I had over the lcmbiar file output, not with query design). I was able to tweak one of the sample queries in this KBA to give me more of what I was after...
SELECT TOP 10000 static, relationships, SI_PARENT_FOLDER_CUID, SI_OWNER, SI_PATH FROM CI_INFOOBJECTS,CI_APPOBJECTS,CI_SYSTEMOBJECTS WHERE (DESCENDENTS ("si_name='Folder Hierarchy'","si_name='<username>'"))
This exports inboxes, personal folders, categories, and roles, which is more than I was after, but still necessary to back up.. so in a way, it is actually better because I have one lcmbiar file per user - contains all their 'personal' objects.
So between narrowing down my set of users to only those who actually have saved things to their personal folder and now having a query that actually returns what I expect it to return, along with the help below for a job to clean up these excessive amounts of promotion jobs I am now creating... I am all set!
Hopefully this can help someone else too!
Thanks,
missy -
Pagination query help needed for large table - force a different index
I'm using a slight modification of the pagination query from over at Ask Tom's: [http://www.oracle.com/technology/oramag/oracle/07-jan/o17asktom.html]
Mine looks like this when fetching the first 100 rows of all members with last name Smith, ordered by join date:
SELECT members.*
FROM members,
SELECT RID, rownum rnum
FROM
SELECT rowid as RID
FROM members
WHERE last_name = 'Smith'
ORDER BY joindate
WHERE rownum <= 100
WHERE rnum >= 1
and RID = members.rowidThe difference between this and the one at Ask Tom's is that my innermost query just returns the ROWID. Then in the outermost query we join the ROWIDs returned to the members table, after we have pruned the ROWIDs down to only the chunk of 100 we want. This makes it MUCH faster (verifiably) on our large tables, as it is able to use the index on the innermost query (well... read on).
The problem I have is this:
SELECT rowid as RID
FROM members
WHERE last_name = 'Smith'
ORDER BY joindateThis will use the index for the predicate column (last_name) instead of the unique index I have defined for the joindate column (joindate, sequence). (Verifiable with explain plan). It is much slower this way on a large table. So I can hint it using either of the following methods:
SELECT /*+ index(members, joindate_idx) */ rowid as RID
FROM members
WHERE last_name = 'Smith'
ORDER BY joindate
SELECT /*+ first_rows(100) */ rowid as RID
FROM members
WHERE last_name = 'Smith'
ORDER BY joindateEither way, it now uses the index of the ORDER BY column (joindate_idx), so now it is much faster as it does not have to do a sort (remember, VERY large table, millions of records). So that seems good. But now, on my outermost query, I join the rowid with the meaningful columns of data from the members table, as commented below:
SELECT members.* -- Select all data from members table
FROM members, -- members table added to FROM clause
SELECT RID, rownum rnum
FROM
SELECT /*+ index(members, joindate_idx) */ rowid as RID -- Hint is ignored now that I am joining in the outer query
FROM members
WHERE last_name = 'Smith'
ORDER BY joindate
WHERE rownum <= 100
WHERE rnum >= 1
and RID = members.rowid -- Merge the members table on the rowid we pulled from the inner queriesOnce I do this join, it goes back to using the predicate index (last_name) and has to perform the sort once it finds all matching values (which can be a lot in this table, there is high cardinality on some columns).
So my question is, in the full query above, is there any way I can get it to use the ORDER BY column for indexing to prevent it from having to do a sort? The join is what causes it to revert back to using the predicate index, even with hints. Remove the join and just return the ROWIDs for those 100 records and it flies, even on 10 million records.
It'd be great if there was some generic hint that could accomplish this, such that if we change the table/columns/indexes, we don't need to change the hint (the FIRST_ROWS hint is a good example of this, while the INDEX hint is the opposite), but any help would be appreciated. I can provide explain plans for any of the above if needed.
Thanks!Lakmal Rajapakse wrote:
OK here is an example to illustrate the advantage:
SQL> set autot traceonly
SQL> select * from (
2 select a.*, rownum x from
3 (
4 select a.* from aoswf.events a
5 order by EVENT_DATETIME
6 ) a
7 where rownum <= 1200
8 )
9 where x >= 1100
10 /
101 rows selected.
Execution Plan
Plan hash value: 3711662397
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1200 | 521K| 192 (0)| 00:00:03 |
|* 1 | VIEW | | 1200 | 521K| 192 (0)| 00:00:03 |
|* 2 | COUNT STOPKEY | | | | | |
| 3 | VIEW | | 1200 | 506K| 192 (0)| 00:00:03 |
| 4 | TABLE ACCESS BY INDEX ROWID| EVENTS | 253M| 34G| 192 (0)| 00:00:03 |
| 5 | INDEX FULL SCAN | EVEN_IDX02 | 1200 | | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("X">=1100)
2 - filter(ROWNUM<=1200)
Statistics
0 recursive calls
0 db block gets
443 consistent gets
0 physical reads
0 redo size
25203 bytes sent via SQL*Net to client
281 bytes received via SQL*Net from client
8 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
101 rows processed
SQL>
SQL>
SQL> select * from aoswf.events a, (
2 select rid, rownum x from
3 (
4 select rowid rid from aoswf.events a
5 order by EVENT_DATETIME
6 ) a
7 where rownum <= 1200
8 ) b
9 where x >= 1100
10 and a.rowid = rid
11 /
101 rows selected.
Execution Plan
Plan hash value: 2308864810
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1200 | 201K| 261K (1)| 00:52:21 |
| 1 | NESTED LOOPS | | 1200 | 201K| 261K (1)| 00:52:21 |
|* 2 | VIEW | | 1200 | 30000 | 260K (1)| 00:52:06 |
|* 3 | COUNT STOPKEY | | | | | |
| 4 | VIEW | | 253M| 2895M| 260K (1)| 00:52:06 |
| 5 | INDEX FULL SCAN | EVEN_IDX02 | 253M| 4826M| 260K (1)| 00:52:06 |
| 6 | TABLE ACCESS BY USER ROWID| EVENTS | 1 | 147 | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter("X">=1100)
3 - filter(ROWNUM<=1200)
Statistics
8 recursive calls
0 db block gets
117 consistent gets
0 physical reads
0 redo size
27539 bytes sent via SQL*Net to client
281 bytes received via SQL*Net from client
8 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
101 rows processed
Lakmal (and OP),
Not sure what advantage you are trying to show here. But considering that we are talking about pagination query here and order of records is important, your 2 queries will not always generate output in same order. Here is the test case:
SQL> select * from v$version ;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL> show parameter optimizer
NAME TYPE VALUE
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 10.2.0.1
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
SQL> show parameter pga
NAME TYPE VALUE
pga_aggregate_target big integer 103M
SQL> create table t nologging as select * from all_objects where 1 = 2 ;
Table created.
SQL> create index t_idx on t(last_ddl_time) nologging ;
Index created.
SQL> insert /*+ APPEND */ into t (owner, object_name, object_id, created, last_ddl_time) select owner, object_name, object_id, created, sysdate - dbms_random.value(1, 100) from all_objects order by dbms_random.random;
40617 rows created.
SQL> commit ;
Commit complete.
SQL> exec dbms_stats.gather_table_stats(user, 'T', cascade=>true);
PL/SQL procedure successfully completed.
SQL> select object_id, object_name, created from t, (select rid, rownum rn from (select rowid rid from t order by created desc) where rownum <= 1200) t1 where rn >= 1190 and t.rowid = t1.rid ;
OBJECT_ID OBJECT_NAME CREATED
47686 ALL$OLAP2_JOIN_KEY_COLUMN_USES 28-JUL-2009 08:08:39
47672 ALL$OLAP2_CUBE_DIM_USES 28-JUL-2009 08:08:39
47681 ALL$OLAP2_CUBE_MEASURE_MAPS 28-JUL-2009 08:08:39
47682 ALL$OLAP2_FACT_LEVEL_USES 28-JUL-2009 08:08:39
47685 ALL$OLAP2_AGGREGATION_USES 28-JUL-2009 08:08:39
47692 ALL$OLAP2_CATALOGS 28-JUL-2009 08:08:39
47665 ALL$OLAPMR_FACTTBLKEYMAPS 28-JUL-2009 08:08:39
47688 ALL$OLAP2_DIM_LEVEL_ATTR_MAPS 28-JUL-2009 08:08:39
47689 ALL$OLAP2_DIM_LEVELS_KEYMAPS 28-JUL-2009 08:08:39
47669 ALL$OLAP9I2_HIER_DIMENSIONS 28-JUL-2009 08:08:39
47666 ALL$OLAP9I1_HIER_DIMENSIONS 28-JUL-2009 08:08:39
11 rows selected.
SQL> select object_id, object_name, last_ddl_time from t, (select rid, rownum rn from (select rowid rid from t order by last_ddl_time desc) where rownum <= 1200) t1 where rn >= 1190 and t.rowid = t1.rid ;
OBJECT_ID OBJECT_NAME LAST_DDL_TIME
11749 /b9fe5b99_OraRTStatementComman 06-FEB-2010 03:43:49
13133 oracle/jdbc/driver/OracleLog$3 06-FEB-2010 03:45:44
37534 com/sun/mail/smtp/SMTPMessage 06-FEB-2010 03:46:14
36145 /4e492b6f_SerProfileToClassErr 06-FEB-2010 03:11:09
26815 /7a628fb8_DefaultHSBChooserPan 06-FEB-2010 03:26:55
16695 /2940a364_RepIdDelegator_1_3 06-FEB-2010 03:38:17
36539 sun/io/ByteToCharMacHebrew 06-FEB-2010 03:28:57
14044 /d29b81e1_OldHeaders 06-FEB-2010 03:12:12
12920 /25f8f3a5_BasicSplitPaneUI 06-FEB-2010 03:11:06
42266 SI_GETCLRHSTGRFTR 06-FEB-2010 03:40:20
15752 /2f494dce_JDWPThreadReference 06-FEB-2010 03:09:31
11 rows selected.
SQL> select object_id, object_name, last_ddl_time from (select t1.*, rownum rn from (select * from t order by last_ddl_time desc) t1 where rownum <= 1200) where rn >= 1190 ;
OBJECT_ID OBJECT_NAME LAST_DDL_TIME
37534 com/sun/mail/smtp/SMTPMessage 06-FEB-2010 03:46:14
13133 oracle/jdbc/driver/OracleLog$3 06-FEB-2010 03:45:44
11749 /b9fe5b99_OraRTStatementComman 06-FEB-2010 03:43:49
42266 SI_GETCLRHSTGRFTR 06-FEB-2010 03:40:20
16695 /2940a364_RepIdDelegator_1_3 06-FEB-2010 03:38:17
36539 sun/io/ByteToCharMacHebrew 06-FEB-2010 03:28:57
26815 /7a628fb8_DefaultHSBChooserPan 06-FEB-2010 03:26:55
14044 /d29b81e1_OldHeaders 06-FEB-2010 03:12:12
36145 /4e492b6f_SerProfileToClassErr 06-FEB-2010 03:11:09
12920 /25f8f3a5_BasicSplitPaneUI 06-FEB-2010 03:11:06
15752 /2f494dce_JDWPThreadReference 06-FEB-2010 03:09:31
11 rows selected.
SQL> select object_id, object_name, last_ddl_time from t, (select rid, rownum rn from (select rowid rid from t order by last_ddl_time desc) where rownum <= 1200) t1 where rn >= 1190 and t.rowid = t1.rid order by last_ddl_time desc ;
OBJECT_ID OBJECT_NAME LAST_DDL_TIME
37534 com/sun/mail/smtp/SMTPMessage 06-FEB-2010 03:46:14
13133 oracle/jdbc/driver/OracleLog$3 06-FEB-2010 03:45:44
11749 /b9fe5b99_OraRTStatementComman 06-FEB-2010 03:43:49
42266 SI_GETCLRHSTGRFTR 06-FEB-2010 03:40:20
16695 /2940a364_RepIdDelegator_1_3 06-FEB-2010 03:38:17
36539 sun/io/ByteToCharMacHebrew 06-FEB-2010 03:28:57
26815 /7a628fb8_DefaultHSBChooserPan 06-FEB-2010 03:26:55
14044 /d29b81e1_OldHeaders 06-FEB-2010 03:12:12
36145 /4e492b6f_SerProfileToClassErr 06-FEB-2010 03:11:09
12920 /25f8f3a5_BasicSplitPaneUI 06-FEB-2010 03:11:06
15752 /2f494dce_JDWPThreadReference 06-FEB-2010 03:09:31
11 rows selected.
SQL> set autotrace traceonly
SQL> select object_id, object_name, last_ddl_time from t, (select rid, rownum rn from (select rowid rid from t order by last_ddl_time desc) where rownum <= 1200) t1 where rn >= 1190 and t.rowid = t1.rid order by last_ddl_time desc
2 ;
11 rows selected.
Execution Plan
Plan hash value: 44968669
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1200 | 91200 | 180 (2)| 00:00:03 |
| 1 | SORT ORDER BY | | 1200 | 91200 | 180 (2)| 00:00:03 |
|* 2 | HASH JOIN | | 1200 | 91200 | 179 (2)| 00:00:03 |
|* 3 | VIEW | | 1200 | 30000 | 98 (0)| 00:00:02 |
|* 4 | COUNT STOPKEY | | | | | |
| 5 | VIEW | | 40617 | 475K| 98 (0)| 00:00:02 |
| 6 | INDEX FULL SCAN DESCENDING| T_IDX | 40617 | 793K| 98 (0)| 00:00:02 |
| 7 | TABLE ACCESS FULL | T | 40617 | 2022K| 80 (2)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("T".ROWID="T1"."RID")
3 - filter("RN">=1190)
4 - filter(ROWNUM<=1200)
Statistics
1 recursive calls
0 db block gets
348 consistent gets
0 physical reads
0 redo size
1063 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
11 rows processed
SQL> select object_id, object_name, last_ddl_time from (select t1.*, rownum rn from (select * from t order by last_ddl_time desc) t1 where rownum <= 1200) where rn >= 1190 ;
11 rows selected.
Execution Plan
Plan hash value: 882605040
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1200 | 62400 | 80 (2)| 00:00:01 |
|* 1 | VIEW | | 1200 | 62400 | 80 (2)| 00:00:01 |
|* 2 | COUNT STOPKEY | | | | | |
| 3 | VIEW | | 40617 | 1546K| 80 (2)| 00:00:01 |
|* 4 | SORT ORDER BY STOPKEY| | 40617 | 2062K| 80 (2)| 00:00:01 |
| 5 | TABLE ACCESS FULL | T | 40617 | 2062K| 80 (2)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("RN">=1190)
2 - filter(ROWNUM<=1200)
4 - filter(ROWNUM<=1200)
Statistics
0 recursive calls
0 db block gets
343 consistent gets
0 physical reads
0 redo size
1063 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
11 rows processed
SQL> select object_id, object_name, last_ddl_time from t, (select rid, rownum rn from (select rowid rid from t order by last_ddl_time desc) where rownum <= 1200) t1 where rn >= 1190 and t.rowid = t1.rid ;
11 rows selected.
Execution Plan
Plan hash value: 168880862
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1200 | 91200 | 179 (2)| 00:00:03 |
|* 1 | HASH JOIN | | 1200 | 91200 | 179 (2)| 00:00:03 |
|* 2 | VIEW | | 1200 | 30000 | 98 (0)| 00:00:02 |
|* 3 | COUNT STOPKEY | | | | | |
| 4 | VIEW | | 40617 | 475K| 98 (0)| 00:00:02 |
| 5 | INDEX FULL SCAN DESCENDING| T_IDX | 40617 | 793K| 98 (0)| 00:00:02 |
| 6 | TABLE ACCESS FULL | T | 40617 | 2022K| 80 (2)| 00:00:01 |
Predicate Information (identified by operation id):
1 - access("T".ROWID="T1"."RID")
2 - filter("RN">=1190)
3 - filter(ROWNUM<=1200)
Statistics
0 recursive calls
0 db block gets
349 consistent gets
0 physical reads
0 redo size
1063 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
11 rows processed
SQL> select object_id, object_name, last_ddl_time from (select t1.*, rownum rn from (select * from t order by last_ddl_time desc) t1 where rownum <= 1200) where rn >= 1190 order by last_ddl_time desc ;
11 rows selected.
Execution Plan
Plan hash value: 882605040
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1200 | 62400 | 80 (2)| 00:00:01 |
|* 1 | VIEW | | 1200 | 62400 | 80 (2)| 00:00:01 |
|* 2 | COUNT STOPKEY | | | | | |
| 3 | VIEW | | 40617 | 1546K| 80 (2)| 00:00:01 |
|* 4 | SORT ORDER BY STOPKEY| | 40617 | 2062K| 80 (2)| 00:00:01 |
| 5 | TABLE ACCESS FULL | T | 40617 | 2062K| 80 (2)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("RN">=1190)
2 - filter(ROWNUM<=1200)
4 - filter(ROWNUM<=1200)
Statistics
175 recursive calls
0 db block gets
388 consistent gets
0 physical reads
0 redo size
1063 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
4 sorts (memory)
0 sorts (disk)
11 rows processed
SQL> set autotrace off
SQL> spool offAs you will see, the join query here has to have an ORDER BY clause at the end to ensure that records are correctly sorted. You can not rely on optimizer choosing NESTED LOOP join method and, as above example shows, when optimizer chooses HASH JOIN, oracle is free to return rows in no particular order.
The query that does not involve join always returns rows in the desired order. Adding an ORDER BY does add a step in the plan for the query using join but does not affect the other query. -
Simple query help in plsql - help
oracle version : 10gR2
indexes are created on each column, is there anyway to make them used while searching for the records rewriting the following query to test given data in any case (lower ,upper)...
SELECT * FROM TX_USERS
WHERE userid like decode( UPPER('Md'),null,userid, UPPER( 'MD')||'%' ) and
first_name like decode(UPPER('Na'),null, first_name, UPPER( 'NA')||'%' ) AND
LAST_name like decode(('Ra'),null, LAST_name, UPPER('RA')||'%' )
-- list goes on..
UPPER('Md') -- is the input values comes from form.. for example i_userid.. this query works fine .. is there anyway of getting indices used without using functional based indexing when we rewrite query like shown below??? input parameter valeus can be anything and table column values can be anything i.e. anycase (upper or lower or mix of both)..
actual code would be
upper(userid) like decode( UPPER(i_userid),null,userid, UPPER( i_userid)||'%' ) and
upper(first_name) like decode(UPPER(i_first_name),null, first_name, UPPER( i_firstname)||'%' )
if we put upper(userid) then index not used ..........anyway of rewriting using it or any other technique... or any other new wayNo, its not working... see the below..
create table test5 as select owner, object_name, subobject_name, object_type from all_objects;
create unique index test5_i5 on test5 (owner, object_name, subobject_name, object_type);
select * from test5 where owner like 'SCOTT' AND OBJECT_NAME LIKE 'EMP';
INDEX RANGE SCAN| TEST5_I5 | 4 | 248 | 1 (0)| 00:00:01 |
but when i use
select * from test5 where UPPER(OWNER) LIKE 'SCOTT%' AND UPPER(OBJECT_NAME) LIKE 'EMP%';
TABLE ACCESS FULL| TEST5 | 3 | 186 | 65 (5)| 00:00:01 |
i know it goes to full scan, i want to know is there any other way to make index used .. without using functional based indx...
the reason is user can search any one of the column data and data is mixed case in table columns and/or conditions specified in query..
.. any help...
not sure how to use 'NLS_SORT=BINARY_CI' on multicolumn index and enable index used in search operation.. ANY OTHER WAY OF DOING THIS...
requirements is
mixed (lower,upper) data stored in db columns and mixed case data searched, 5 columns specified in where condition, data may be provided in search conditon to one or two or to all 5 columns in mixed case... matching records need to be returned.. suggest a good way of doing this... thnx -
I'm having trouble with an SQL query. I've created a simple logon page wherein a user will enter their user name and password. The program will look in an Access database for the user name, sort it by Date/Time modified, and check to see if their password matches the most recent password. Unfortunately, the query returns no results. I'm absolutely certain that I'm doing the query correctly (I've imported it directly from my old VB6 code). Something simple is eluding me. Any help would be appreciated.
private void LogOn() {
//make sure that the user name/password is valid, then load the main menu
try {
//open the database connection
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:LawOffice2000", "", "");
Statement select = con.createStatement();
String strTemp = "Select * From EMPLOYEES Where INITIALS = '" + txtUserName.getText() + "' Order By DATE Desc, TIME Desc";
ResultSet result = select.executeQuery(strTemp);
while(result.next()) {
if (txtPassword.getPassword().toString() == result.getString("Password")) {
MenuMain.main();
else {
System.out.println("Password Bad");
System.out.println(txtUserName.getText());
System.out.println(result.getString("Password"));
break; //exit loop
//close the connection
con.close(); }
catch (Exception e) {
System.out.println("LawOfficeSuite_LogOn: " + e);
return; }
}The problem is here: "txtPassword.getPassword().toString() == result.getString("Password"))"
Don't confuse String's equals() method with the equality operator '=='. The == operator checks that two references refer to the same object. If you want to compare the contents of Strings (whether two strings contain the same characters), use equals(), e.g. if (str1.equals(str2))...
Example:String s1 = "foo";
String s2 = new String("foo");
System.out.println("s1 == s2: " + (s1 == s2)); // false
System.out.println("s1.equals(s2): " + (s1.equals(s2))); // trueFor more information, check out Comparison operators: equals() versus == -
Simple button help needed!
I want to make a simple round button that glows when you
mouse over it and depresses when you click it.
Apparently to do this I need to use Filters to make the glow
and bevels. But Filtersonly work on movie clips, buttons and text.
So I make a circle and convert it into a button symbol
(Btn1). Then I make another button symbol (Btn2) and use the first
button symbol (Btn 1) on the Up Over and Down frames of Btn 2.
Assorted Filters are applied to Btn 1 on the Up Over and Down
frames to get the effects I want.
I test the button (Btn2) using Enable Simple Buttons. It
works perfectly - glows on mouse over and depresses on click. Then
I try Test Movie -- and the button doesn't work!!!
Not does it work when exported as a SWF file!!!
I watched a tutorial video that came with my Flash Pro 8
Hands-On-Training (HOT) book and he used pretty much the same
technique -- except he only tested his button with Enable Simple
Buttons. I'll bet my house his didn't work with Test Movie either!
The stupid thing, is I was just able to achieve exactly what
I wanted very quickly using LiveMotion 2!
What is wrong here? Why is it so impossible to create a glow
button in Flash? Why has it been easy in Live Motion for years?
All help appreciated!
Thanks
craigI thought the nesting button situation might be the problem
BUT there is no other way to apply Filters to Up, Down, etc. Also,
a freaking tutorial book described that as a valid method, but
obviously it ain't.
I tried using movieclips as well but basically had the same
problem.
I mentioned LiveMotion 2 because that ancient program can do
easily what Flash Pro 8 seems incapable of.
What is the logic behind not allowing Filters to be applied
to simple graphics? It's absurd!
There's got to be a way... -
Hi,
Need help in writing a query.
SQL> SELECT xmlelement("P",xmlforest(P.process_id AS Ppid),
2 xmlagg(xmlelement("PI",XMLFOREST( PI.question_id AS PIqid,
3 PI.process_id AS PIpid,
4 PI.innertext AS PItext),
5 xmlagg(Xmlelement("PO",xmlforest( PO.option_id AS POoid,
6 PO.question_id AS POqid,
7 PO.process_id AS popid
8 ))
9 ORDER BY PO.option_id))
10 ORDER BY PI.question_id ) )
11 FROM liveProcess_ec P
12 INNER JOIN vw_liveProcessItem_Sim_v6 PI
13 ON P.process_id = PI.process_id
14 LEFT OUTER JOIN vw_liveProcessOption_Sim_v6 PO
15 ON PI.question_id = PO.question_id
16 AND PI.process_id = PO.process_id
17 WHERE p.process_id =450
18 GROUP BY p.process_id,PI.question_id,PI.process_id,PI.innertext
19 ORDER BY p.process_id;
SELECT xmlelement("P",xmlforest(P.process_id AS Ppid),
ERROR at line 1:
ORA-00937: not a single-group group functionThanks in advanceHi,
Here below are the create table scripts along with sample data and expected output.
CREATE TABLE VW_LIVEPROCESSOPTION_SIM_v6
( "OPTION_ID" NUMBER,
"QUESTION_ID" NUMBER(10,0),
"PROCESS_ID" NUMBER(10,0),
"OPT_INNERTEXT" VARCHAR2(200 CHAR),
"OPT_LINKFROM" VARCHAR2(20 CHAR),
"OPT_LINKTO" VARCHAR2(20 CHAR),
"LIBQUESTION_IDFK" NUMBER,
"LIBOPTION_IDFK" NUMBER
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,2,450,'Yes',null,'5',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,3,450,'Yes',null,'5',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,5,450,'Yes',null,'6',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,6,450,'Yes',null,'7',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,8,450,'Block All',null,'9',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,9,450,'Yes',null,'10',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,11,450,'Yes',null,'12',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,12,450,'Yes',null,'13',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,14,450,'Yes',null,'16',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,2,450,'No',null,'3',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,3,450,'No',null,'4',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,5,450,'No',null,'8',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,6,450,'No',null,'8',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,8,450,'Standard',null,'11',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,9,450,'No',null,'11',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,11,450,'No',null,'14',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,12,450,'No',null,'14',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,14,450,'No',null,'15',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (3,8,450,'Disabled',null,'12',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (4,8,450,'User Defined',null,'12',null,null);
REATE TABLE "VW_LIVEPROCESSITEM_SIM_v6"
( "QUESTION_ID" NUMBER(10,0),
"PROCESS_ID" NUMBER(10,0),
"INNERTEXT" VARCHAR2(200 CHAR),
"ITEMTYPE" VARCHAR2(50 CHAR),
"LINKFROM" VARCHAR2(500 CHAR),
"LINKTO" VARCHAR2(500 CHAR),
"ASSOCIATED" VARCHAR2(200 CHAR),
"CONTENT_ID" NUMBER,
"EXITPOINT1_ID" NUMBER(10,0),
"EXITPOINT2_ID" NUMBER(10,0),
"EXITPOINT3_ID" NUMBER(10,0),
"RESOLVEIDENTIFIER" VARCHAR2(40 CHAR),
"LIBQUESTION_IDFK" NUMBER(10,0),
"FOLLOWONCALL" NUMBER(1,0),
"USERINPUT" VARCHAR2(200 CHAR),
"ISLOCKED" NUMBER(1,0),
"PREVIOUSANSWER" NUMBER(1,0),
"VISIBLETOAGENT" NUMBER(1,0),
"RETRYATTEMPT" NUMBER(10,0),
"TAGS" VARCHAR2(50 BYTE)
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (1,450,'CBB1015 - Router Firewall Settinngs Process','Title',null,'2',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (2,450,'Is the customers PC Firewall turned off?','Question','1','2.2,2.1',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (3,450,'Advise the customer to turn off the PC Firewall in order to continue. Has this been done?','Question','2.2','3.2,3.1',null,278,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (4,450,'Advise the customer the PC Firewall must be switched off before this process????','ExitPoint','3.2',null,null,null,14,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (5,450,'Is the customer able to access the internet now?','Question','3.1,2.1','5.2,5.1',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (6,450,'Is the customer having a problem with a specific website?','Question','5.1','6.2,6.1',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (7,450,'1536: CBB1008 - Browser Setup and Daignostics','SubProcess','6.1',null,'1536-1-0',null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (8,450,'What is the security level on the CPE Management page?','Question','6.2,5.2','8.4,8.3,8.2,8.1',null,279,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (9,450,'Change the security level to Standard. Does this resolve the customers issue?','Question','8.1','9.2,9.1',null,280,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (10,450,'Issue Resolved','ExitPoint','9.1',null,null,null,1,6,122,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (11,450,'Change the security level to Disabled. Is the customer able to browse the internet?','Question','9.2,8.2','11.2,11.1',null,281,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (12,450,'Change the security level to Standard. Is the customer able to browse the internet now?','Question','11.1,8.3,8.4','12.2,12.1',null,283,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (13,450,'Issue Resolved','ExitPoint','12.1',null,null,null,1,6,123,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (14,450,'Ask the customer to perform a master reset. Does this resolve their issue?','Question','12.2,11.2','14.2,14.1',null,282,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (15,450,'Faulty CPE','ExitPoint','14.2',null,null,null,1,6,124,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (16,450,'Issue Resolved','ExitPoint','14.1',null,null,null,1,6,123,null,null,null,null,null,null,null,null,null);
CREATE TABLE "LIVEPROCESS_EC_V"
( "PROCESS_ID" NUMBER(10,0),
"USER_ID" NUMBER(10,0),
"CREATED" TIMESTAMP (6)
Insert into LIVEPROCESS_EC (PROCESS_ID,USER_ID,CREATED) values (450,7460,to_timestamp('21-APR-08 09.34.41.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'));Expected Output
<P>
<Ppid>450</Ppid>
<Pn>CBB1015 - Router Firewall Settinngs Process</Pn>
<Pg>9</Pg>
<Pl>0</Pl>
<Pb>5</Pb>
<qcount>100</qcount>
<ocount>200</ocount>
<PI>
<PIqid>1</PIqid>
<PIpid>450</PIpid>
<PIpx>366</PIpx>
<PIpy>-516</PIpy>
<PItext>CBB1015 - Router Firewall Settinngs Process</PItext>
<PItype>Title</PItype>
<PIto>2</PIto>
<PO />
</PI>
<PI>
<PIqid>2</PIqid>
<PIpid>450</PIpid>
<PIpx>366</PIpx>
<PIpy>-437</PIpy>
<PItext>Is the customers PC Firewall turned off?</PItext>
<PItype>Question</PItype>
<PIfrom>1</PIfrom>
<PIto>2.2,2.1</PIto>
<PO>
<POoid>1</POoid>
<POqid>2</POqid>
<popid>450</popid>
<POpx>-50</POpx>
<POpy>70</POpy>
<POtext>Yes</POtext>
<POto>5</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>2</POqid>
<popid>450</popid>
<POpx>50</POpx>
<POpy>70</POpy>
<POtext>No</POtext>
<POto>3</POto>
</PO>
</PI>
<PI>
<PIqid>3</PIqid>
<PIpid>450</PIpid>
<PIpx>468</PIpx>
<PIpy>-344</PIpy>
<PItext>Advise the customer to turn off the PC Firewall in order to continue. Has this been done?</PItext>
<PItype>Question</PItype>
<PIfrom>2.2</PIfrom>
<PIto>3.2,3.1</PIto>
<PIc>278</PIc>
<PO>
<POoid>1</POoid>
<POqid>3</POqid>
<popid>450</popid>
<POpx>-50</POpx>
<POpy>70</POpy>
<POtext>Yes</POtext>
<POto>5</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>3</POqid>
<popid>450</popid>
<POpx>50</POpx>
<POpy>70</POpy>
<POtext>No</POtext>
<POto>4</POto>
</PO>
</PI>
<PI>
<PIqid>4</PIqid>
<PIpid>450</PIpid>
<PIpx>571</PIpx>
<PIpy>-250</PIpy>
<PItext>Advise the customer the PC Firewall must be switched off before this process????</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>3.2</PIfrom>
<PIe1>14</PIe1>
<PO />
</PI>
<PI>
<PIqid>5</PIqid>
<PIpid>450</PIpid>
<PIpx>374</PIpx>
<PIpy>-240</PIpy>
<PItext>Is the customer able to access the internet now?</PItext>
<PItype>Question</PItype>
<PIfrom>3.1,2.1</PIfrom>
<PIto>5.2,5.1</PIto>
<PO>
<POoid>1</POoid>
<POqid>5</POqid>
<popid>450</popid>
<POpx>-50</POpx>
<POpy>70</POpy>
<POtext>Yes</POtext>
<POto>6</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>5</POqid>
<popid>450</popid>
<POpx>50</POpx>
<POpy>70</POpy>
<POtext>No</POtext>
<POto>8</POto>
</PO>
</PI>
<PI>
<PIqid>6</PIqid>
<PIpid>450</PIpid>
<PIpx>322</PIpx>
<PIpy>-141</PIpy>
<PItext>Is the customer having a problem with a specific website?</PItext>
<PItype>Question</PItype>
<PIfrom>5.1</PIfrom>
<PIto>6.2,6.1</PIto>
<PO>
<POoid>1</POoid>
<POqid>6</POqid>
<popid>450</popid>
<POpx>-50</POpx>
<POpy>70</POpy>
<POtext>Yes</POtext>
<POto>7</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>6</POqid>
<popid>450</popid>
<POpx>50</POpx>
<POpy>70</POpy>
<POtext>No</POtext>
<POto>8</POto>
</PO>
</PI>
<PI>
<PIqid>7</PIqid>
<PIpid>450</PIpid>
<PIpx>128</PIpx>
<PIpy>-36</PIpy>
<PItext>1536: CBB1008 - Browser Setup and Daignostics</PItext>
<PItype>SubProcess</PItype>
<PIfrom>6.1</PIfrom>
<PIas>1536-1-0</PIas>
<PO />
</PI>
<PI>
<PIqid>8</PIqid>
<PIpid>450</PIpid>
<PIpx>461</PIpx>
<PIpy>-43</PIpy>
<PItext>What is the security level on the CPE Management page?</PItext>
<PItype>Question</PItype>
<PIfrom>6.2,5.2</PIfrom>
<PIto>8.4,8.3,8.2,8.1</PIto>
<PIc>279</PIc>
<PO>
<POoid>1</POoid>
<POqid>8</POqid>
<popid>450</popid>
<POpx>-112</POpx>
<POpy>89</POpy>
<POtext>Block All</POtext>
<POto>9</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>8</POqid>
<popid>450</popid>
<POpx>50</POpx>
<POpy>70</POpy>
<POtext>Standard</POtext>
<POto>11</POto>
</PO>
<PO>
<POoid>3</POoid>
<POqid>8</POqid>
<popid>450</popid>
<POpx>83</POpx>
<POpy>116</POpy>
<POtext>Disabled</POtext>
<POto>12</POto>
</PO>
<PO>
<POoid>4</POoid>
<POqid>8</POqid>
<popid>450</popid>
<POpx>-14</POpx>
<POpy>94</POpy>
<POtext>User Defined</POtext>
<POto>12</POto>
</PO>
</PI>
<PI>
<PIqid>9</PIqid>
<PIpid>450</PIpid>
<PIpx>237</PIpx>
<PIpy>76</PIpy>
<PItext>Change the security level to Standard. Does this resolve the customers issue?</PItext>
<PItype>Question</PItype>
<PIfrom>8.1</PIfrom>
<PIto>9.2,9.1</PIto>
<PIc>280</PIc>
<PO>
<POoid>1</POoid>
<POqid>9</POqid>
<popid>450</popid>
<POpx>-50</POpx>
<POpy>70</POpy>
<POtext>Yes</POtext>
<POto>10</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>9</POqid>
<popid>450</popid>
<POpx>69</POpx>
<POpy>73</POpy>
<POtext>No</POtext>
<POto>11</POto>
</PO>
</PI>
<PI>
<PIqid>10</PIqid>
<PIpid>450</PIpid>
<PIpx>158</PIpx>
<PIpy>185</PIpy>
<PItext>Issue Resolved</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>9.1</PIfrom>
<PIe1>1</PIe1>
<PIe2>6</PIe2>
<PIe3>122</PIe3>
<PO />
</PI>
<PI>
<PIqid>11</PIqid>
<PIpid>450</PIpid>
<PIpx>821</PIpx>
<PIpy>144</PIpy>
<PItext>Change the security level to Disabled. Is the customer able to browse the internet?</PItext>
<PItype>Question</PItype>
<PIfrom>9.2,8.2</PIfrom>
<PIto>11.2,11.1</PIto>
<PIc>281</PIc>
<PO>
<POoid>1</POoid>
<POqid>11</POqid>
<popid>450</popid>
<POpx>-50</POpx>
<POpy>70</POpy>
<POtext>Yes</POtext>
<POto>12</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>11</POqid>
<popid>450</popid>
<POpx>50</POpx>
<POpy>70</POpy>
<POtext>No</POtext>
<POto>14</POto>
</PO>
</PI>
<PI>
<PIqid>12</PIqid>
<PIpid>450</PIpid>
<PIpx>474</PIpx>
<PIpy>186</PIpy>
<PItext>Change the security level to Standard. Is the customer able to browse the internet now?</PItext>
<PItype>Question</PItype>
<PIfrom>11.1,8.3,8.4</PIfrom>
<PIto>12.2,12.1</PIto>
<PIc>283</PIc>
<PO>
<POoid>1</POoid>
<POqid>12</POqid>
<popid>450</popid>
<POpx>-50</POpx>
<POpy>70</POpy>
<POtext>Yes</POtext>
<POto>13</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>12</POqid>
<popid>450</popid>
<POpx>50</POpx>
<POpy>70</POpy>
<POtext>No</POtext>
<POto>14</POto>
</PO>
</PI>
<PI>
<PIqid>13</PIqid>
<PIpid>450</PIpid>
<PIpx>322</PIpx>
<PIpy>278</PIpy>
<PItext>Issue Resolved</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>12.1</PIfrom>
<PIe1>1</PIe1>
<PIe2>6</PIe2>
<PIe3>123</PIe3>
<PO />
</PI>
<PI>
<PIqid>14</PIqid>
<PIpid>450</PIpid>
<PIpx>645</PIpx>
<PIpy>327</PIpy>
<PItext>Ask the customer to perform a master reset. Does this resolve their issue?</PItext>
<PItype>Question</PItype>
<PIfrom>12.2,11.2</PIfrom>
<PIto>14.2,14.1</PIto>
<PIc>282</PIc>
<PO>
<POoid>1</POoid>
<POqid>14</POqid>
<popid>450</popid>
<POpx>-50</POpx>
<POpy>70</POpy>
<POtext>Yes</POtext>
<POto>16</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>14</POqid>
<popid>450</popid>
<POpx>50</POpx>
<POpy>70</POpy>
<POtext>No</POtext>
<POto>15</POto>
</PO>
</PI>
<PI>
<PIqid>15</PIqid>
<PIpid>450</PIpid>
<PIpx>768</PIpx>
<PIpy>435</PIpy>
<PItext>Faulty CPE</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>14.2</PIfrom>
<PIe1>1</PIe1>
<PIe2>6</PIe2>
<PIe3>124</PIe3>
<PO />
</PI>
<PI>
<PIqid>16</PIqid>
<PIpid>450</PIpid>
<PIpx>479</PIpx>
<PIpy>420</PIpy>
<PItext>Issue Resolved</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>14.1</PIfrom>
<PIe1>1</PIe1>
<PIe2>6</PIe2>
<PIe3>123</PIe3>
<PO />
</PI>
</P>Thanks in advance. -
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! -
Simple viewer help needed please
I need help with this exact problem please which was posted by Kirby on 9th Feb
I can't save into the idisk/web folder although I can copy the files over after they refuse to open (if that means anything)...
"This is for Old Toad. I checked out your demo site which is awesome. I read the tutorial,
Examples of SimpleViewer and Flash Album Exporter Slideshows (plugins for iPhoto)
ADDED USING HTML SNIPPET AND IFRAME
This was great but I am still running into a roadblock. The issue seems to be that in the URL that is given on your demo page...
http://web.me.com/youraccountname/slideshow folder/index.html
....it says to enter my account name (which I did).
I am uploading the simple-viewer folder to my iDisk using the Go menu but inside of the Web/Sites folder there is no folder called Slideshow Folder. So am I right in thinking that the URL has nothing to point too because that folder isn't there? Why isn't it there? And is there anything I can do to solve this? Is there another place the simple-viewer folder should be on my idisk?"Hi:
When you create the simpleviewer slideshow with iPhoto's plugin there should be a folder created on your HD that contains the items seen in the screenshot below:
The folder was named simpleviewer because that's what I named it during the export from iPhoto. That's the same folder as I refer to as "Slideshow folder". It can be whatever you name it when exporting from iPhoto. Upload that folder to your iDisk/Web/Sites folder as shown below:
In the iFrame code use the following URL to the index.html file inside the simpleviewer folder:
http://web.me.com/YourMMe_AccountName/simplerviewer/index.html
That should do it. -
IPS event query ** Help needed badly**
Greetings all. Apologies for the dramatic headline but I'm in a bit of a time crunch.
I have a 4215 running 6.0(3)E1. The device is inline. Below is an event which triggered,
========================
evIdsAlert: eventId=1184881408377311643 severity=low vendor=Cisco
originator:
hostId: xyz
appName: sensorApp
appInstanceId: 380
time: 2007/09/24 15:11:25 2007/09/24 15:11:25 UTC
signature: description=Recognized content type id=12673 version=S149
subsigId: 0
sigDetails: Recognized content type
marsCategory: Info/Misc
interfaceGroup: vs0
vlan: 0
participants:
attacker:
addr: locality=any a.a.a.a
port: 80
target:
addr: locality=any b.b.b.b
port: 51095
os: idSource=unknown relevance=relevant type=unknown
actions:
deniedFlow: true
context:
fromAttacker: <stuff>
riskRatingValue: attackRelevanceRating=relevant targetValueRating=medium 50
threatRatingValue: 15
interface: fe2_1
protocol: tcp
========================
I have an external application which pull this same event from the sensor using a query *like* the following,
wget --user foo --password hoo http://a.b.c.d/cgi-bin/event-server?events=evAlert
I'm able to pull most of the event information but not all. What I can't seem to get from query is the " deniedFlow: true" value. I'm seeing something like,
></attack></participants><actions></actions></evAlert>
Notice the "deniedFlow: true" information missing between action.
Is my wget-ish query missing some arguments which is preventing me from pulling all the same information I can see from the CLI?
Thanks in advance.The problem is that you are using the 5.x-style event-server and so you do not see all of the event fields. You need to change the app to pull from the "sdee-server" and then you will see all of the event fields:
http://a.b.c.d/cgi-bin/sdee-server?events=evAlert -
Duplicate invoice. Query help needed
Hi All,
We need to build a query which addresses the following condition
Some of the invoices were created against the wrong vendors and that money needs to be recovered. Some of them are already recovered while some are not
* list out all the duplicate invoices between a particular date range(invoice date) with same invoice num ,same invoice amount and same invoice date.
* If there are any debit invoice created(invoice number postfixed with CR or ADJ),those particualr invoices should not be included.
The table below shows two type of invoice, the one with bold(invoice num=193666) has debit invoice created and all the three records related to it should not be a part of output data
while the record(invoice num=00017321) should be a part of output data.
INVOICE_NUM INVOICE_AMOUNT VENDOR_NUMBER INVOICE_DATE ORG_ID
00017321 233.35 A321 1-Dec-11 95
00017321 233.35 K452 1-Dec-11 95
*193666 101.67 EM9B 18-May-12 91*
*193666 101.67 1B02 18-May-12 91*
*193666CR -101.67 1B02 18-May-12 91*
Below is the query which i wrote to identify the duplicate invoice
select distinct
a1.invoice_amount,
a1.invoice_num,
(select segment1 from apps.po_vendors where vendor_id=a1.vendor_id) vendor_name,
a1.invoice_date,
A1.ORG_ID
from apps.ap_invoices_all a1,
apps.ap_invoices_all a2
where 1=1
and a1.org_id in (91,95)
and a1.org_id in (91,95)
and a1.invoice_date between (to_DATE('01-SEP-2011','DD-MON-YYYY')) AND (to_DATE('01-JUN-2012','DD-MON-YYYY'))
and a2.invoice_date between (to_DATE('01-SEP-2011','DD-MON-YYYY')) AND (to_DATE('01-JUN-2012','DD-MON-YYYY'))
and a2.invoice_num=a1.invoice_num
and a1.invoice_amount=a2.invoice_amount
and a1.invoice_id<>a2.invoice_id
and a1.invoice_amount<>0
order by a1.invoice_amount,a1.invoice_num
Can anybody share their thoughts on how to modify the query above which checks if there are any debit invoice created and not include in the final output.
Thanks in advanceHow do I ask a question on the forums?
SQL and PL/SQL FAQ -
I know that Position is the abstract data type and that it supports only one method - element() (that returns the element stored in this position).. Now when I wish to implement a List (with doubly linked list) using the Interface List...In the Interface List there are quite few methods to implement , however, few of them require Position parameter...And this is where I am getting confused..What is the Position parameter? A number? or? Here is a sample code
//Node class for implementing a Doubly linked list
Class DoublyNode implements Position
{ public DoublyNode prev, next;
public Object element
//constructor
public Dnode()
{ prev = null
next = null
element = null
public Object element(){
return element;
Class NodeList implements List{
// bunch of methods and variables
public Position before(Position p) // What is Position parameter? a position number? or what?
{ DoublyNode v = (DoublyNode)p;
DoublyNode prev = v.prev;
return prev;
Now I know since DoublyNode implements Position, we can cast a position to a node, but what is that Position parameter? Can anybody explain this minor detail to me? Or how do these Position parameters work in programing? All I know is, given a position parameter (what ?) the Doubly linked list will instantly locate the appropriate node (how) and you can cast it to a node and return the node...but how does this Position work?
I am aware of the fact that everytime you insert in the list , that inserted element gets a position (a number?) how do I refer/catch back that node ? Via position (number)?
Please Help....
I appreciate it a lot!!!There's no standard Java class called Position, at least none that has anything to do with lists or collections. So this must be a class or interface that somebody else wrote. At any rate, a Position parameter needs a Position object, obvious as that may sound. How do you create a Position object? Somebody with documentation of the Position class or interface might be able to help here -- is this homework?
-
Hello,
I have an output from the query, but that is not what I am looking for. The final result set should be like the one shown below in the image. Please let me know any ideas or input how to achieve the final results I am looking for. Thank you for your time
and help.
JaganIf you provide example data as a table, and DDL I'll take a look for you. Images are not useful to us at all.
Ex:
DECLARE @table TABLE (col1 INT, col2 VARCHAR(20))
INSERT INTO @table (col1, col2) VALUES
(1, 'AAAA'),(2, 'CCCC')
Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question.
Maybe you are looking for
-
ITunes list doesn't show up in media browser
I'm just starting with Final Cut Pro X. When I click on the "Music and Sound" button, and select iTunes, nothing shows up on the list. My iTunes is open, and I have plenty of things that should show up. What should I do?
-
Hi. I'm new in Java, especially JDBC technology. I'm creating simple oracle client which retrieves huge load of data. I've just wondered is it possibe to search for data in resultset with a sql query ? Thanks in advance, Regards.
-
Why do I have Japanese next to my firefox logo on top bar?
At the very top left of my screen where the firefox logo is, a succession of Japanese letters occurs. It changes when I change web pages as if it's labeling my pages in Japanese or something. My selected language is English so I don't understand what
-
I am wasting money all the time and need help to rectify this. i restart and re log into my account and still have to purchase movies twice
-
I can't sign in. Lync return wrong password but I can garantee that it's right.
I've many computers that are configured in a domain server. This trouble happen in Lync 2010 Vista and Seven edition. On the Windows 7 I'm updating it for Lync 2013, but I can't do same thing on Vista cause it's no compatible. The problem happen whe