Query help needed
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.
Similar Messages
-
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. -
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! -
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 -
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 -
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 == -
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 -
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. -
Query help needed for Sales order panel user field query.
I have a user defined form field on sales order row level called = U_DEPFEEAMT
1, I would like this field to get the value from a field on this sales order row level multiplied by what is in point 2 below. The details of field in point 1 is :
Form=139, item=38, pane=1, column=10002117, and row=1
2. The contents in field 1 should be multiplied by a value coming from another user field linked to OITM master item.
The details of user field attached to OITM is :
OITM.U_DepositFeeON
Appreciate your help.
Thank you.Try this one:
SELECT T0.U_DepositFeeON*$[$38.10002117.number\]
FROM dbo.OITM T0
WHERE T0.ItemCode = $[$38.1.0\]
Thanks,
Gordon -
Tweak for sql query - help needed for smalll change
Hi.
I am trying to run a script that checks for used space on all tablespaces and returns the results.
So far so good:
set lines 200 pages 2000
col tablespace_name heading 'Tablespace' format a30 truncate
col total_maxspace_mb heading 'MB|Max Size' format 9G999G999
col total_allocspace_mb heading 'MB|Allocated' format 9G999G999
col used_space_mb heading 'MB|Used' format 9G999G999D99
col free_space_mb heading 'MB|Free Till Max' like used_space_mb
col free_space_ext_mb heading 'MB|Free Till Ext' like used_space_mb
col pct_used heading '%|Used' format 999D99
col pct_free heading '%|Free' like pct_used
break on report
compute sum label 'Total Size:' of total_maxspace_mb total_allocspace_mb used_space_mb - free_space_mb (used_space_mb/total_maxspace_mb)*100 on report
select
alloc.tablespace_name,
(alloc.total_allocspace_mb - free.free_space_mb) used_space_mb,
free.free_space_mb free_space_ext_mb,
((alloc.total_allocspace_mb - free.free_space_mb)/alloc.total_maxspace_mb)*100 pct_used,
((free.free_space_mb+(alloc.total_maxspace_mb-alloc.total_allocspace_mb))/alloc.total_maxspace_mb)*100 pct_free
FROM (SELECT tablespace_name,
ROUND(SUM(CASE WHEN maxbytes = 0 THEN bytes ELSE maxbytes END)/1048576) total_maxspace_mb,
ROUND(SUM(bytes)/1048576) total_allocspace_mb
FROM dba_data_files
WHERE file_id NOT IN (SELECT FILE# FROM v$recover_file)
GROUP BY tablespace_name) alloc,
(SELECT tablespace_name,
SUM(bytes)/1048576 free_space_mb
FROM dba_free_space
WHERE file_id NOT IN (SELECT FILE# FROM v$recover_file)
GROUP BY tablespace_name) free
WHERE alloc.tablespace_name = free.tablespace_name (+)
ORDER BY pct_used DESC
The above returns something like this:
MB MB % %
Tablespace Used Free Till Ext Used Free
APPS_TS_ARCHIVE 1,993.13 54.88 97.32 2.68
APPS_TS_TX_IDX 14,756.13 1,086.88 91.37 8.63
APPS_TS_TX_DATA 20,525.75 594.25 80.18 19.82
APPS_TS_MEDIA 6,092.00 180.00 74.37 25.63
APPS_TS_INTERFACE 13,177.63 366.38 71.49 28.51
The above works fine, but I would like to further change the query so that only those tablespaces with free space less than 5% (or used space more than 95%) are returned.
I have been working on this all morning and wanted to open it up to the masters!
I have tried using WHERE pct_used > 95 but to no avail.
Any advice would be appreciated.
Many thanks.
10.2.0.4
Linux Red Hat 4.Thanks for that.
What is confusing is that the below query works for every other (about 10 others) database but not this one (?)
SQL> set lines 200 pages 2000
SQL>
SQL> col tablespace_name heading 'Tablespace' format a30 truncate
SQL> col total_maxspace_mb heading 'MB|Max Size' format 9G999G999
SQL> col total_allocspace_mb heading 'MB|Allocated' format 9G999G999
SQL> col used_space_mb heading 'MB|Used' format 9G999G999D99
SQL> col free_space_mb heading 'MB|Free Till Max' like used_space_mb
SQL> col free_space_ext_mb heading 'MB|Free Till Ext' like used_space_mb
SQL> col pct_used heading '%|Used' format 999D99
SQL> col pct_free heading '%|Free' like pct_used
SQL>
SQL> break on report
SQL> compute sum label 'Total Size:' of total_maxspace_mb total_allocspace_mb used_space_mb - free_space_mb (used_space_mb/total_maxspace_mb)*100 on report
SQL>
SQL> select /*+ALL_ROWS */
2 alloc.tablespace_name,
3 alloc.total_maxspace_mb,
4 alloc.total_allocspace_mb,
5 (alloc.total_allocspace_mb - free.free_space_mb) used_space_mb,
6 free.free_space_mb+(alloc.total_maxspace_mb-alloc.total_allocspace_mb) free_space_mb,
7 free.free_space_mb free_space_ext_mb,
8 ((alloc.total_allocspace_mb - free.free_space_mb)/alloc.total_maxspace_mb)*100 pct_used,
9 ((free.free_space_mb+(alloc.total_maxspace_mb-alloc.total_allocspace_mb))/alloc.total_maxspace_mb)*100 pct_free
10 FROM (SELECT tablespace_name,
11 ROUND(SUM(CASE WHEN maxbytes = 0 THEN bytes ELSE maxbytes END)/1048576) total_maxspace_mb,
12 ROUND(SUM(bytes)/1048576) total_allocspace_mb
13 FROM dba_data_files
14 WHERE file_id NOT IN (SELECT FILE# FROM v$recover_file)
15 GROUP BY tablespace_name) alloc,
16 (SELECT tablespace_name,
17 SUM(bytes)/1048576 free_space_mb
18 FROM dba_free_space
19 WHERE file_id NOT IN (SELECT FILE# FROM v$recover_file)
20 GROUP BY tablespace_name) free
21 WHERE alloc.tablespace_name = free.tablespace_name (+)
22 ORDER BY pct_used DESC
23 /
((alloc.total_allocspace_mb - free.free_space_mb)/alloc.total_maxspace_mb)*100 pct_used,
ERROR at line 8:
ORA-01476: divisor is equal to zero -
Enter Requisition Form Query - Help Needed
Hi Forum,
I have a requirement to modify the lov for the Category field in the Enter Requisition form and add a new field.
The item is in the block :LINES.ITEM_CATEGORY.
So, I ftp'd the form and libraries onto my local drive which is in the FORMS60_PATH. When I open the form, it opens without any error. But it does not attach any libraries in it ?
Anyway, I looked at the form item and its a Text Item with a Lov 'ENABLE_LIST_LAMP' and a record Group with the same name. But this is a dummy record group.
Where is the Actual Query for this Record Group built ? I assume it is in some library, but how do i find which library ?
I cannot see anything in the WHEN-NEW-ITEM-INSTANCE or any other trigger having the query.
The Category is a KFF actually.
Thanks
S.
Edited by: user565538 on Mar 25, 2009 6:12 AMone more thing i notice is I can see in the KFF definition , the Value set = PO_ITEM_CATEGORY
But when I try to query for this Value set (of type independent) , in System Adminsitrator, no value set is being returned !
Am i missing something ? where are the values coming from ? -
Query help needed in finding max value between two columns
I have a table as follows:
-- INSERTING into TESTTABLE
Insert into TESTTABLE (COLA,COL2,COLC,COLD,COLE,COLF) values ('A','4.5','AA',0.3,'AB',5.5);
Insert into TESTTABLE (COLA,COL2,COLC,COLD,COLE,COLF) values ('B','1','BB',2.5,'BC',6.9);
Insert into TESTTABLE (COLA,COL2,COLC,COLD,COLE,COLF) values ('C','2.6','CC',3.3,'CD',1.4);
Insert into TESTTABLE (COLA,COL2,COLC,COLD,COLE,COLF) values ('D','1.8','DD',2.9,'DE',1.2);
Insert into TESTTABLE (COLA,COL2,COLC,COLD,COLE,COLF) values ('E','6.8','EE',4.8,'EF',9.6);
Insert into TESTTABLE (COLA,COL2,COLC,COLD,COLE,COLF) values ('F','2.0','FF',6.34,'FG',3.9);
Insert into TESTTABLE (COLA,COL2,COLC,COLD,COLE,COLF) values ('G','1.7','GG',3.6,'GH',5.8);
I want to get results as follows:
COLA COL2 MaxCol MaxColVal
A 4.5 AB 5.5
B 1 BC 6.9
C 2.6 CC 3.3
D 1.8 DD 2.9
E 6.8 EF 9.6
F 2.0 FF 6.34
G 1.7 GH 5.8I want to get the max value of either of the columns COLD or COLF.. Whichever column has got max value, then the corresponding value of COLC and COLE should be returned..
For eg., in first row, COLF has higher value than COLD.. ie., COLF = 5.5 > COLD = 0.3, so for row1, i want the result as MaxCol is AB and MaxColvalue is 5.5..
Similarly for third row, COLD =3.3 > COLF=1.4, so for 3rd row, i want the result as MaxCol is CC and MaxColvalue is 3.3
How is it possible to do this in a qery? Any help.. please..SQL> select cola
2 , col2
3 , case greatest(cold,colf)
4 when cold then colc
5 else cole
6 end maxcol
7 , greatest(cold,colf) maxcolval
8 from testtable
9 /
C COL MA MAXCOLVAL
A 4.5 AB 5,5
B 1 BC 6,9
C 2.6 CC 3,3
D 1.8 DD 2,9
E 6.8 EF 9,6
F 2.0 FF 6,34
G 1.7 GH 5,8
7 rijen zijn geselecteerd.Regards,
Rob. -
Hi
Need a querey
Emp_no Dept_no DAY_DIM_FROM_ID DAY_DIM_TO_ID system_last_updated_date
98871 1 1/1/1900 8/12/2007 8/13/2007
98871 2 8/13/2007 12/31/9999 8/13/2007
98871 3 8/13/2007 12/31/9999 8/13/2007 only one of these
In the above table IS EMP_NO =98871 WITH DEPT_NO WITH DAY_DIM_FROM_ID 2 records.
I want to maintain only on latest record of emp_no = 98871 and day_dim_from_id =8/13/2007
note :there is no time stamp. date columns are trunc(sysdate)
Only this is example .I dont want hard coded..SQL> With t As
2 (Select 98871 Emp_no , 1 Dept_no , to_date('8/13/2007','mm/dd/rrrr')DAY_DIM_FROM From dual Union All
3 Select 98871 Emp_no , 2 Dept_no , to_date('8/13/2007','mm/dd/rrrr')DAY_DIM_FROM From dual Union All
4 Select 98871 Emp_no , 3 Dept_no , to_date('8/13/2007','mm/dd/rrrr')DAY_DIM_FROM From dual
5 )
6 Select t.Emp_no,
7 t.Dept_no,
8 t.DAY_DIM_FROM
9 From t,
10 (
11 Select Emp_no,
12 Max(Dept_no) deptno
13 From t
14 Group By Emp_no
15 ) inv
16 Where t.Emp_no = inv.emp_no
17 And t.dept_no = inv.deptno;
EMP_NO DEPT_NO DAY_DIM_FROM
98871 3 8/13/2007
SQL>
Maybe you are looking for
-
Can I set up an ipad without an apple id
I have bought an ipad for my dad as a surprise but want to set it up as we are going abroad for his borthday and may not have access to wifi etc there so want it to be ready to go - he has an apple id but I don't know it so is it best to choose not t
-
I am using standard batch input LSMW for creating info records with obj 0060 and program RM06IBI0. In the last step while running session I am getting error as 'Field EINE-EVERS. (shipping instructions ) is not an input field.' Does anybody know why?
-
Hello, How can I embed a web link in the SAPScript so that when the form is sent out as an email, the receiver can click on the web link for more detail information. Thanks.
-
Pb for printing reports using Hyperion Analyzer 7.2
<p>Hello,<br><br>Firstly, apologize for my bad english, because i am french...<br><br>I have a problem when i try to print reports that contains more thaone spreadsheets with Hyperion Analyzer v7.2: only the selectedspreadsheet is printed, not the en
-
Create DVD menu in Photoshop - font show pixels
I googled and search this forum and feel not help me at all. I created DVD menu in photoshop (CS4) for DVD Studio Pro 4. I selected Film & Video NTSC DV widescreen(SD). Export file as .tif. Create DVD. Font look pixel on HDTV. Is there a way to impro