Help needed for writing query
help needed for writing query
i have the following tables(with data) as mentioned below
FK*-foregin key (SUBJECTS)
FK**-foregin key (COMBINATION)
1)SUBJECTS(table name)
SUB_ID(NUMBER) SUB_CODE(VARCHAR2) SUB_NAME (VARCHAR2)
2 02 Computer Science
3 03 Physics
4 04 Chemistry
5 05 Mathematics
7 07 Commerce
8 08 Computer Applications
9 09 Biology
2)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2) SUB_ID1(NUMBER(FK*)) SUB_ID2(NUMBER(FK*)) SUB_ID3(NUMBER(FK*)) SUBJ_ID4(NUMBER(FK*))
383 S1 9 4 2 3
384 S2 4 2 5 3
---------I actually designed the ABOVE table also like this
3) a)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2)
383 S1
384 S2
b)COMBINATION_DET
COMBDET_ID(NUMBER) COMB_ID(FK**) SUB_ID(FK*)
1 383 9
2 383 4
3 383 2
4 383 3
5 384 4
6 384 2
7 384 5
8 384 3
Business rule: a combination consists of a maximum of 4 subjects (must contain)
and the user is less relevant to a COMB_NAME(name of combinations) but user need
the subjects contained in combinations
i need the following output
COMB_ID COMB_NAME SUBJECT1 SUBJECT2 SUBJECT3 SUBJECT4
383 S1 Biology Chemistry Computer Science Physics
384 S2 Chemistry Computer Science Mathematics Physics
or even this is enough(what i actually needed)
COMB_ID subjects
383 Biology,Chemistry,Computer Science,Physics
384 Chemistry,Computer Science,Mathematics,Physics
you can use any of the COMBINATION table(either (2) or (3))
and i want to know
1)which design is good in this case
(i think SUB_ID1,SUB_ID2,SUB_ID3,SUB_ID4 is not a
good method to link with same table but if 4 subjects only(and must) comes
detail table is not neccessary )
now i am achieving the result by program-coding in C# after getting the rows from oracle
i am using oracle 9i (also ODP.NET)
i want to know how can i get the result in the stored procedure itsef.
2)how it could be designed in any other way.
any help/suggestion is welcome
thanks for your time --Pradeesh
Well I forgot the table-alias, here now with:
SELECT C.COMB_ID
, C.COMB_NAME
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID1) AS SUBJECT_NAME1
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID2) AS SUBJECT_NAME2
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID3) AS SUBJECT_NAME3
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID4) AS SUBJECT_NAME4
FROM COMBINATION C;
As you need exactly 4 subjects, the columns-solution is just fine I would say.
Similar Messages
-
Hi,
Could anyone help me in writing below query without syntax errors.
I tried but no luck
select xmlelement("g", XMLATTRIBUTES(g.contentgroup_id as "id",g.groupname as "label",
(select xmlagg(xmlelement ("c",XMLATTRIBUTES(c.title as "title",c.content_id as "id")))) as "A"))
as "A" from
(SELECT g.contentgroup_id AS id, g.groupname AS label, c.title AS label, c.content_id AS id
FROM content_ec c FULL OUTER JOIN contentgroup_ec g ON c.group_id = g.contentgroup_id
oRDER BY g.groupname ,c.title ASC );
Any help really appreciated.
ThanksFew tips to get your question answered here
1. Give your database version. Some thing that does not work in one version works fine in the next. And 8i,9i or 10g is not version. best way to give the version is to query your v$version table like this.
SQL> select * from v$version where rownum = 1
2 /
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod2. You should understand we don't have what you have, meaning you should provide your data structure and some sample data for us to help.
3. "I got an error"... "Its not working"... and the list goes on. Sentences like this does not help. If you got a error past the entire error. If stuff does not work, tell us the details.
4. Just don't throw some output and say i want it. Please explain to every one how you derive it.
5. And the most important thing. Use \...\ tag to format. Please.. Please.. Please.. use it. It helps every one a lot. When you use it your SQL looks some thing like this.
SELECT xmlelement("g", XMLATTRIBUTES(g.contentgroup_id as "id",g.groupname as "label",
(select xmlagg(xmlelement ("c",XMLATTRIBUTES(c.title as "title",c.content_id as "id")))) as "A")) as "A"
FROM (SELECT g.contentgroup_id AS id,
g.groupname AS label,
c.title AS label,
c.content_id AS id
FROM content_ec c
FULL OUTER JOIN contentgroup_ec g
ON c.group_id = g.contentgroup_id
ORDER BY g.groupname ,c.title ASC );6. And also do search this forum. Most of your my queries are answered by simple search.
Thanks,
Karthick. -
Help needed for writing a Query.
I want to write a query in SSRS, SQL Server 2012, Report Builder 3.0. There is 3 tables as follows
Table A
ID Name
1 AAAAA
2 BBBBB
Table B
ID BS
1 5000
2 3000
Table C
ID Allowance
Amt
1 HRA
500
1 TA
200
2 HRA
300
Output Expected
ID Name
BS HRA
TA
1 AAAAA
5000 500
200
2 BBBBB
3000 300
0
ShareefThis is the result from the above code:
id Name BS Allowance TA
1 AAAAA 5000 500 200
2 BBBBB 3000 300 0
Please mark this reply as answer if it solved your issue or vote as helpful if it helped.
[Blog]
But I am getting something like this.
id
Name BS Allowance TA
1
AAAAA 5000 500
1
AAAAA
200
2 BBBBB
3000 300 0
Shareef -
hello ,
I am a beginner in terms of writing sql queries. I hope some body can help me out.
I have two tables
mysql> desc user_group_t;
---------------------------------------------------+
| Field | Type | Null | Key | Default | Extra |
---------------------------------------------------+
| userAccountId | char(8) | | PRI | | |
| groupId | char(8) | | PRI | | |
---------------------------------------------------+
2 rows in set (0.00 sec)
mysql> desc group_t;
---------------------------------------------------+
| Field | Type | Null | Key | Default | Extra |
---------------------------------------------------+
| id | char(8) | | PRI | | |
| name | char(50) | YES | | NULL | |
| email | char(100) | YES | | NULL | |
| description | char(254) | YES | | NULL | |
| parentId | char(8) | YES | | NULL | |
| creatorId | char(8) | YES | | NULL | |
| createDate | char(20) | YES | | NULL | |
| updateDate | char(20) | YES | | NULL | |
| updatorId | char(8) | YES | | NULL | |
---------------------------------------------------+
9 rows in set (0.00 sec)
what I want is list of all groups with id,name and #of members(which is the # of rows in the user_group_t for any given id). Importantly I need the groups with 0 members also to be listed. In short my output should contain exactly the same number of rows as in group_t table with an additional column indicating # of members for that group.
Any help would be greatly appreciated.
Thanks in Advance.
-VasanthThanks Donald,
Actually I figured it out, with the following query:
select id,name,sum(if(groupid is not null,1,0)) as members from group_t left join user_group_t on id=groupid group by id;
I tried your solution, but mysql says there is an error at '+' . Anyway I modified your solution to the one below and it worked.
select a.id, a.name, count(b.groupid) from group_t a left join user_group_t b on a.id=b.groupid group by a.id, a.name;
I tried that before but then I used Count(*) instead of count on groupid. Your solution is elagant and I will go with yours.
Thanks again.
Vasanth -
Color management help needed for adobe CS5 and Epson printer 1400-Prints coming out too dark with re
Color management help needed for adobe CS5 and Epson printer 1400-Prints coming out too dark with reddish cast and loss of detail
System: Windows 7
Adobe CS5
Printer: Epson Stylus Photo 1400
Paper: Inkjet matte presentation paper with slight luster
Installed latest patch for Adobe CS5
Epson driver up to date
After reading solutions online and trying them for my settings for 2 days I am still unable to print what I am seeing on my screen in Adobe CS5. I calibrated my monitor, but am not sure once calibration is saved if I somehow use this setting in Photoshop’s color management.
The files I am printing are photographs of dogs with lots of detail I digitally painted with my Wacom tablet in Photoshop CS5 and then printed with Epson Stylus 1400 on inkjet paper 20lb with slight luster.
My Printed images lose a lot of the detail & come out way to dark with a reddish cast and loss of detail when I used these settings in the printing window:
Color Handling: Photoshop manages color, Color management -ICM, OFF no color adjustment.
When I change to these settings in printer window: Color Handling: Printer manages color. Color management- Color Controls, 1.8 Gamma and choose Epson Standard it prints lighter, but with reddish cast and very little detail and this is the best setting I have used so far.
Based on what I have read on line, I think the issue is mainly to do with what controls are set in the Photoshop Color Settings window and the Epson Printer preferences. I have screen images attached of these windows and would appreciate knowing what you recommend I enter for each choice.
Also I am confused as to what ICM color management system to use with this printer and CS5:
What is the best ICM to use with PS CS5 & the Epson 1400 printer? Should I use the same ICM for both?
Do I embed the ICM I choose into the new files I create?
Do I view all files in the CS5 workspace in this default ICM?
Do I set my monitor setting to the same ICM?
If new file opens in CS5 workspace and it has a different embedded profile than my workspace, do I convert it?
Do I set my printer, Monitor and PS CS5 color settings to the same ICM?
Is using the same ICM for all devices what is called a consistent workflow?
I appreciate any and all advice that can be sent my way on this complicated issue. Thank you in advance for your time and kind help.It may be possible to figure out by watching a Dr.Brown video on the subject of color printing. Adobe tv
I hope this may help............... -
File missing (file\BCD error code 0Xc0000034 help need for work!
file missing (file\BCD error code 0Xc0000034 help need for work! what can i do?
have an p 2000 notebook pcHi bobkunkle, welcome to the HP Forums. I understand you cannot boot passed the error you are receiving.
What is the model or product number of your notebook? What version of Windows is installed?
Guide to finding your product number
Which Windows operating system am I running?
TwoPointOh
I work on behalf of HP
Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
Click the “Kudos, Thumbs Up" on the bottom to say “Thanks” for helping! -
Help me for writing the password script on solaris
hi,
help me for writing password scripts to change the user/root password.
in the script itself myself want to mention the new password.
now user want to login with the new password only.
model script:
echo $test:`perl -e '$x=crypt('$test123','test');
print $x'`::::::: >> /etc/shadow
test--->username
test123---->new password.
the above script is not working.
kindly help me for writing the script.
Regards,
rajaWell. For one thing, if you just append the new password to the /etc/shadow file there will be two entries for the user in that file (at least if the user already had a password). Which probably is a bad thing.
-
Help need for force to signout All session ! how...
hi
help need for force to signout All session ! how ??
Solved!
Go to Solution.Hi and welcome to the Skype Community,
To force a signout of all instances your Skype is signed into please change your password: https://support.skype.com/en/faq/FA95/how-do-i-change-my-password
Follow the latest Skype Community News
↓ Did my reply answer your question? Accept it as a solution to help others, Thanks. ↓ -
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 All,
I am new to oracle.I have a requirement. i need to display sales fields for a particular time as below.
Time Sales
6-7 3333
7-8 45345
8-9 546
But the min time and max time are coming from different query and sales fields coming from different.Now i need to join both queries to get the results.But there is no common column.I tried with sub query there also i am getting error.Please find the queries and help me
Hour Group Query:
select
time1.*,
(select if (time_format(dt.curr_time, '%H') <
time_format(ifnull((SELECT prop_value FROM cust_conv_properties c where prop_key = 'DayStartingTime'), '00:00:00'), '%H'),
date_format(date_add(dt.curr_time, INTERVAL 0 DAY),'%d/%m/%Y'),
date_format(dt.curr_time,'%d/%m/%Y')) as curr_date
from
(select concat(date_format(str_to_date('23/10/2011','%d/%m/%Y'),'%Y-%m-%d'), ' ', '00:00:00') as curr_time) dt) as report_date
from
(select
-- 'S' temp,
cast(min(cchg.from_hour) as unsigned) as min_value,
cast(max(cchg.to_hour) as unsigned) as max_value,
concat(concat(min(cchg.from_hour),''),'-',concat(max(cchg.to_hour),'')) as time_diff
from
cust_conv_hour_group as cchg
where
cchg.group_value in (SELECT distinct if(group_value = (SELECT min(group_value) FROM cust_conv_hour_group),
(SELECT max(group_value) FROM cust_conv_hour_group), group_value-1) as group_value
FROM cust_conv_hour_group c where from_hour <= cast(time_format('23:00:00','%H') as unsigned)
and
to_hour > cast(time_format('00:00:00','%H') as unsigned))
group by
cchg.group_value
) time1
Sales Fields Query:
SELECT
if(count(cons.wr_tarSale)=0,0, cons.wr_tarSale) wr_tarSale,
if(count(cons.wr_actSale)=0,0, cons.wr_actSale) wr_actSale,
if(count(cons.wr_tarTrans)=0,0, cons.wr_tarTrans) wr_tarTrans,
if(count(cons.wr_actTrans)=0,0, cons.wr_actTrans) wr_actTrans,
if(count(cons.tarSale)=0,0, cons.tarSale) tarSale,
if(count(cons.actSale)=0,0, cons.actSale) actSale,
if(count(cons.varSale)=0,0, cons.varSale) varSale,
if(count(cons.tarTrans)=0,0, cons.tarTrans) tarTrans,
if(count(cons.actTrans)=0,0, cons.actTrans) actTrans,
if(count(cons.actAds)=0,0, cons.actAds) actAds,
if(count(cons.actUpt)=0,0, cons.actUpt) actUpt,
if(count(cons.tarAds)=0,0, cons.tarAds) tarAds,
if(count(cons.tarUpt)=0,0, cons.tarUpt) tarUpt,
if(count(cons.actConv)=0,0, cons.actConv) actConv,
if(count(cons.tarTplh)=0,0, cons.tarTplh) tarTplh,
if(count(cons.actBlank1)=0,0, cons.actBlank1) actBlank1,
if(count(cons.actBlank2)=0,0, cons.actBlank2) actBlank2,
if(count(cons.actTplh)=0,0, cons.actTplh) actTplh,
if(count(cons.sDTarSale)=0,0, cons.sDTarSale)sDTarSale,
if(count(cons.sDTarTrans)=0,0, cons.sDTarTrans)sDTarTrans,
if(count(cons.sDTarQty)=0,0, cons.sDTarQty)sDTarQty,
if(count(cons.sDTarFF)=0,0, cons.sDTarFF)sDTarFF
FROM
SELECT
ifnull(sum(ccsr.target_sale),0) wr_tarSale,
ifnull(sum(ccsr.actual_sale),0) wr_actSale,
ifnull(sum(ccsr.actual_transaction_count),0) wr_actTrans,
ifnull(sum(ccsr.target_transaction_count),0) wr_tarTrans,
round(ifnull(sum(ccsr.target_sale),0),2) tarSale,
round(ifnull(sum(ccsr.actual_sale),0),2) actSale,
round(round(ifnull(sum(ccsr.actual_sale),0),2)- round(ifnull(sum(ccsr.target_sale),0),2),2) varSale,
round(ifnull(sum(ccsr.actual_transaction_count),0),0) actTrans,
round(ifnull(sum(ccsr.target_transaction_count),0),0) tarTrans,
0 actBlank1,
round(ifnull((sum(ccsr.actual_sale)/sum(ccsr.actual_transaction_count)),0),2) actAds,
round(ifnull((sum(ccsr.target_sale)/sum(ccsr.target_transaction_count)),0),2) tarAds,
round(ifnull((sum(ccsr.actual_quantity)/sum(ccsr.actual_transaction_count)),0),2) actUpt,
round(ifnull((sum(ccsr.target_quantity)/sum(ccsr.target_transaction_count)),0),2) tarUpt,
round(ifnull((sum(ccsr.actual_transaction_count)/sum(ccsr.actual_footfalls))*100,0),2) actConv,
0 actBlank2,
0 actBlank3,
round(ifnull((sum(ccsr.actual_footfalls)/sum(ccsr.actual_man_hours)),0),2) actTplh,
round(ifnull((sum(ccsr.target_footfalls)/sum(ccsr.target_man_hours)),0),2) tarTplh,
round(ifnull(ccsrs.target_sale,0),2) as sDTarSale,
round(ifnull(ccsrs.target_transaction_count,0),0) as sDTarTrans,
ifnull(ccsrs.target_quantity,0) as sDTarQty,
ifnull(ccsrs.target_footfalls,0) as sDTarFF
FROM
cust_conv_store_report ccsr
inner join cust_conv_store_report_summary ccsrs on(ccsrs.brand_code=ccsr.brand_code and ccsrs.category=ccsr.category and
ccsrs.store_date=ccsr.store_date and ccsrs.value_type=ccsr.value_type)
WHERE
ccsr.value_type='B' and
ccsr.brand_code= ? AND
ccsr.store_date = date_format(str_to_date(?,'%d/%m/%Y'),'%Y-%m-%d')
AND HOUR((TIME(ccsr.transaction_time))) >= (?) AND HOUR((TIME(ccsr.transaction_time)))< (?)
GROUP BY
ccsr.brand_code
) cons;
Edited by: 992887 on Mar 10, 2013 4:25 AM992887 wrote:
Hi All,
I am new to oracle.code below is NOT valid Oracle syntax.
post results from valid Oracle SQL below
SELECT * FROM V$VERSION;
I have a requirement. i need to display sales fields for a particular time as below.
Time Sales
6-7 3333
7-8 45345
8-9 546
But the min time and max time are coming from different query and sales fields coming from different.Now i need to join both queries to get the results.But there is no common column.I tried with sub query there also i am getting error.Please find the queries and help me
Hour Group Query:
select
time1.*,
(select if (time_format(dt.curr_time, '%H') <
time_format(ifnull((SELECT prop_value FROM cust_conv_properties c where prop_key = 'DayStartingTime'), '00:00:00'), '%H'),
date_format(date_add(dt.curr_time, INTERVAL 0 DAY),'%d/%m/%Y'),
date_format(dt.curr_time,'%d/%m/%Y')) as curr_date
from
(select concat(date_format(str_to_date('23/10/2011','%d/%m/%Y'),'%Y-%m-%d'), ' ', '00:00:00') as curr_time) dt) as report_date
from
(select
-- 'S' temp,
cast(min(cchg.from_hour) as unsigned) as min_value,
cast(max(cchg.to_hour) as unsigned) as max_value,
concat(concat(min(cchg.from_hour),''),'-',concat(max(cchg.to_hour),'')) as time_diff
from
cust_conv_hour_group as cchg
where
cchg.group_value in (SELECT distinct if(group_value = (SELECT min(group_value) FROM cust_conv_hour_group),
(SELECT max(group_value) FROM cust_conv_hour_group), group_value-1) as group_value
FROM cust_conv_hour_group c where from_hour <= cast(time_format('23:00:00','%H') as unsigned)
and
to_hour > cast(time_format('00:00:00','%H') as unsigned))
group by
cchg.group_value
) time1
Sales Fields Query:
SELECT
if(count(cons.wr_tarSale)=0,0, cons.wr_tarSale) wr_tarSale,
if(count(cons.wr_actSale)=0,0, cons.wr_actSale) wr_actSale,
if(count(cons.wr_tarTrans)=0,0, cons.wr_tarTrans) wr_tarTrans,
if(count(cons.wr_actTrans)=0,0, cons.wr_actTrans) wr_actTrans,
if(count(cons.tarSale)=0,0, cons.tarSale) tarSale,
if(count(cons.actSale)=0,0, cons.actSale) actSale,
if(count(cons.varSale)=0,0, cons.varSale) varSale,
if(count(cons.tarTrans)=0,0, cons.tarTrans) tarTrans,
if(count(cons.actTrans)=0,0, cons.actTrans) actTrans,
if(count(cons.actAds)=0,0, cons.actAds) actAds,
if(count(cons.actUpt)=0,0, cons.actUpt) actUpt,
if(count(cons.tarAds)=0,0, cons.tarAds) tarAds,
if(count(cons.tarUpt)=0,0, cons.tarUpt) tarUpt,
if(count(cons.actConv)=0,0, cons.actConv) actConv,
if(count(cons.tarTplh)=0,0, cons.tarTplh) tarTplh,
if(count(cons.actBlank1)=0,0, cons.actBlank1) actBlank1,
if(count(cons.actBlank2)=0,0, cons.actBlank2) actBlank2,
if(count(cons.actTplh)=0,0, cons.actTplh) actTplh,
if(count(cons.sDTarSale)=0,0, cons.sDTarSale)sDTarSale,
if(count(cons.sDTarTrans)=0,0, cons.sDTarTrans)sDTarTrans,
if(count(cons.sDTarQty)=0,0, cons.sDTarQty)sDTarQty,
if(count(cons.sDTarFF)=0,0, cons.sDTarFF)sDTarFF
FROM
SELECT
ifnull(sum(ccsr.target_sale),0) wr_tarSale,
ifnull(sum(ccsr.actual_sale),0) wr_actSale,
ifnull(sum(ccsr.actual_transaction_count),0) wr_actTrans,
ifnull(sum(ccsr.target_transaction_count),0) wr_tarTrans,
round(ifnull(sum(ccsr.target_sale),0),2) tarSale,
round(ifnull(sum(ccsr.actual_sale),0),2) actSale,
round(round(ifnull(sum(ccsr.actual_sale),0),2)- round(ifnull(sum(ccsr.target_sale),0),2),2) varSale,
round(ifnull(sum(ccsr.actual_transaction_count),0),0) actTrans,
round(ifnull(sum(ccsr.target_transaction_count),0),0) tarTrans,
0 actBlank1,
round(ifnull((sum(ccsr.actual_sale)/sum(ccsr.actual_transaction_count)),0),2) actAds,
round(ifnull((sum(ccsr.target_sale)/sum(ccsr.target_transaction_count)),0),2) tarAds,
round(ifnull((sum(ccsr.actual_quantity)/sum(ccsr.actual_transaction_count)),0),2) actUpt,
round(ifnull((sum(ccsr.target_quantity)/sum(ccsr.target_transaction_count)),0),2) tarUpt,
round(ifnull((sum(ccsr.actual_transaction_count)/sum(ccsr.actual_footfalls))*100,0),2) actConv,
0 actBlank2,
0 actBlank3,
round(ifnull((sum(ccsr.actual_footfalls)/sum(ccsr.actual_man_hours)),0),2) actTplh,
round(ifnull((sum(ccsr.target_footfalls)/sum(ccsr.target_man_hours)),0),2) tarTplh,
round(ifnull(ccsrs.target_sale,0),2) as sDTarSale,
round(ifnull(ccsrs.target_transaction_count,0),0) as sDTarTrans,
ifnull(ccsrs.target_quantity,0) as sDTarQty,
ifnull(ccsrs.target_footfalls,0) as sDTarFF
FROM
cust_conv_store_report ccsr
inner join cust_conv_store_report_summary ccsrs on(ccsrs.brand_code=ccsr.brand_code and ccsrs.category=ccsr.category and
ccsrs.store_date=ccsr.store_date and ccsrs.value_type=ccsr.value_type)
WHERE
ccsr.value_type='B' and
ccsr.brand_code= ? AND
ccsr.store_date = date_format(str_to_date(?,'%d/%m/%Y'),'%Y-%m-%d')
AND HOUR((TIME(ccsr.transaction_time))) >= (?) AND HOUR((TIME(ccsr.transaction_time)))< (?)
GROUP BY
ccsr.brand_code
) cons;
Edited by: 992887 on Mar 10, 2013 4:25 AM -
XMLAGG structure, performance help needed for odd nesting in schema
Hello,
I have to produce XML to look like:
<?xml version='1.0'?>
<enterprise>
<membership>
<sourcedid>
<id>PHYS_101_001_FA2007</id>
</sourcedid>
<!-- NOTE: absence of "members" level tag for XMLAGG! -->
<member>
<sourcedid>
<id>D2LU0001</id>
</sourcedid>
<role roletype="Sample Role">
<status>1</status>
</role>
</member>
<member>
<sourcedid>
<id>D2LU0002</id>
</sourcedid>
<role roletype="Sample Role">
<status>1</status>
</role>
</member>
</membership>
</enterprise>This would be straightforward if the schema allowed for a "<members>" tag under which to nest the <member> tags. But, it does not allow for that tag or any other than those listed above.
I have a query which does produce that output (except for the roletype attribute), but its performance is horrible; it takes about 40 minutes to return data:
SELECT
XMLROOT(
XMLELEMENT("enterprise",
XMLAGG(
XMLELEMENT("membership",
XMLFOREST( XMLELEMENT("id",cx.mapped_course_id) as "sourcedid"
(SELECT XMLAGG(
XMLELEMENT("member",
XMLFOREST(XMLELEMENT("id",spriden_id) AS "sourcedid",
XMLELEMENT("status",'1') AS "role"
FROM enrollments_fall_sfrstca efs
, spriden sp
, gzv_tuid t
WHERE sp.spriden_change_ind IS NULL
AND sp.spriden_pidm = t.pidm
AND t.tuid = efs.user_name
AND efs.mapped_course_id = cx.mapped_course_id
AND efs.term = cx.semester
, VERSION '1.0', STANDALONE NO VALUE)
FROM courses_xt cx
WHERE cx.semester = :term_code
;Similar queries are producing courses and users XML fine with no performance issues, but these are driven off either the courses view or the enrollments view, but not both.
Is there some other way I can produce the nesting I need for the vendor's schema?
The source views are basically as follows (showing relevant columns only):
courses_xt:
MAPPED_COURSE_ID SEMEST
AVFT209-13307-201210 201210
AVFT210-13308-201210 201210enrollments_fall_sfrstca:
MAPPED_COURSE_ID USER_NAME
AVFT209-13307-201210 FULLERC8
AVFT209-13307-201210 SHUPEK
AVFT209-13307-201210 NOMAN
AVFT210-13308-201210 SHUPEK
AVFT210-13308-201210 PELLONMWhen I have the query without the XML (with the subquery as a column of the outer query), this returns the correct data quickly (a couple of minutes).
I have tried various permutations of XMLFOREST, XMLELEMENT, XMLAGG but either I get syntax errors, or the data is wrong (e.g. repeated '<membership>' for each '<member>', or I have to create an invalid tag '<members>' to be filtered later).
Please advise!
Thanks,
Anita LeesHi Anita,
Have you tried with a GROUP BY and no subquery?
Here's an example using SCOTT schema.
I've used the same tag names and structure so that you can see the analogy :
SELECT XMLElement("enterprise",
XMLAgg(
XMLElement("membership",
XMLElement("sourceid", xmlelement("id", d.deptno))
, XMLAgg(
XMLElement("member",
XMLElement("sourceid",
XMLElement("id", e.empno)
, XMLElement("role",
XMLAttributes(e.job as "roletype")
, XMLElement("status", '1')
FROM scott.dept d
LEFT OUTER JOIN scott.emp e ON e.deptno = d.deptno
WHERE d.deptno IN (10,20)
GROUP BY d.deptno
;which gives :
<enterprise>
<membership>
<sourceid>
<id>10</id>
</sourceid>
<member>
<sourceid>
<id>7782</id>
</sourceid>
<role roletype="MANAGER">
<status>1</status>
</role>
</member>
<member>
<sourceid>
<id>7934</id>
</sourceid>
<role roletype="CLERK">
<status>1</status>
</role>
</member>
<member>
<sourceid>
<id>7839</id>
</sourceid>
<role roletype="PRESIDENT">
<status>1</status>
</role>
</member>
</membership>
<membership>
<sourceid>
<id>20</id>
</sourceid>
<member>
<sourceid>
<id>7369</id>
</sourceid>
<role roletype="CLERK">
<status>1</status>
</role>
</member>
<member>
<sourceid>
<id>7902</id>
</sourceid>
<role roletype="ANALYST">
<status>1</status>
</role>
</member>
<member>
<sourceid>
<id>7566</id>
</sourceid>
<role roletype="MANAGER">
<status>1</status>
</role>
</member>
</membership>
</enterprise> -
URGENT HELP NEEDED FOR GROUP BY
SELECT curve_date, curve_id, curve_type, curve_name, curve_instance, is_simple,
comments, curve_currency, curve_generator, curve_interpolator, holidays,
user_name, rate_index, daycount_code, frequency_code, rate_index_tenor,
time_zone
FROM curve a
WHERE curve_date = (SELECT max(curve_date)
FROM curve b
WHERE b.curve_id = a.curve_id
GROUP BY curve_id)
I have this query ..This query does the FULL TABLE SCAN .....PLEASE Suggest some easier way to optimize this query.....I need it VERY VERY URGENTLY....SELECT curve_date, curve_id, curve_type, curve_name, curve_instance, is_simple,
comments, curve_currency, curve_generator, curve_interpolator, holidays,
user_name, rate_index, daycount_code, frequency_code, rate_index_tenor,
time_zone
FROM curve
WHERE (curve_id, curve_date) IN (SELECT curve_id, max(curve_date)
FROM curve
GROUP BY curve_id)
Be sure you have statistics collected on the table. Anyway, I am not sure that Oracle will not do the FTS for this query even if curve_id and curve_date are indexed. -
Help needed for using BASIC authentication through JDBCRealm
Help needed.
Hello,
I am doing a degree project, so far it works fine in my local machine, I need to try it on my virtual hosting (as it is a live server).
My project requires JDBCRealm, that is BASIC authentication loading access data from mysql database. Normally this setup can be done in Server.xml file, because my Tomcat hosting is a virtual one, I only have permission to access the web.xml file.
My question is: is it possible to get it done in an alternative way? In web.xml? Some properties file maybe?
Thank you very much.You can set this up for your context using META-INF/context.xml instead of working with server.xml.
Make a directory called META-INF under your webapp ( it'll be at the same level as WEB-INF ). Under this, add a context.xml with all your context specific configuration including the realm. A sample is below
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/myApp" reloadable="true">
<Realm
className="org.apache.catalina.realm.JDBCRealm"
driverName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
connectionURL="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=myDB;SelectMethod=Cursor;"
connectionName="username" connectionPassword="password"
digest="MD5" userTable="users" userNameCol="userid" userCredCol="userpassword"
userRoleTable="user_roles" roleNameCol="rolename"
/>
</Context>Hope this helps.
People on the forum help others voluntarily, it's not their job.
Help them help you.
Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
---------------------------------------------------------------- -
Help needed in writing a function.
I am using Oracle 11g and SQL plus. I am a complete newbie, so I need some help here in writing a function. I guess my question is more about writing the trigonometric functions within the function.
latA, longA latB, longB // these are the four input parameters,
theta = longA - longB
distX = sin( latA * PI / 180) * sin ( latB * PI /180) + cos ( latA * PI/180) * cos ( latB * PI/180) * cos ( theta * PI / 180)
distY = acos(distX) // this is arc cosine
distZ = distY * 180 / PI // PI refers to the mathematical PI
distP = distZ * 60 * 1.1515; // this value should be returned. Of course the intermediate variable names don't matter.
Please help. Thanks.CREATE OR REPLACE FUNCTION fucntion_name(latA IN NUMBER, longA IN NUMBER, latB IN NUMBER, longB IN NUMBER) RETURN NUMBER
IS
pi CONSTANT NUMBER:=3.14159;
theta NUMBER;
distX NUMBER;
distY NUMBER;
distZ NUMBER;
distP NUMBER;
BEGIN
theta :=longA - longB;
distX :=sin( latA * PI /180) * sin ( latB * PI /180) + cos ( latA * PI/180) * cos ( latB * PI/180) * cos ( theta * PI / 180);
distY :=acos(distX); --this is arc cosine
distZ :=distY * 180/PI; --PI refers to the mathematical PI
distP :=distZ * 60 * 1.1515; --this value should be returned. Of course the intermediate variable names don't matter.
RETURN distP;
END;Edited by: Ora on May 3, 2011 11:46 PM
Maybe you are looking for
-
Hi Guys I recently bought a second hand early 2011 Macbook Pro 15 inch and are having 2 problems. The first is that none of the apps detects my webcam at all, the second is, i have Windows 8 installed on bootcamp but are unable to get the keyboard ba
-
How to start with XSLT Mapping
Hi Everyone, How to learn XSLT Mapping,Error Analysis,Triggering alerts and Trouble shooting in XI.Plz could anyone help to get through these areas?I'm facing many problems in my inetrviews in the above mentioned areas.I eagerly waiting for the r
-
Non PO invoice : Vendor payment terms
Hi I tried to replicate backend payment terms to SRM by report BBP_UPLOAD_PAYMENT_TERMS. I am not getting any payment terms from BE in SRM as payment condition. I have assigned payment terms in Backend and even in SRM, assigned with manual created pa
-
MSI K8N Neo2 Help!!!!!
My system is running perfectly fine but some how the core cell utility keep beeping. Im not sure what is happending. Anyone have similiar problem? Here is the screenshot of my core cell reading.here
-
E3000 severe drop in speed from ethernet connection to wireless
I have an E3000 connected to COMCAST. My download speed with an Ethernet connection to my computer (Windows 7) is just over 60Mbbs. When I connect to the internet using wireless only (computer adjacent to the router), my download speed drops 50% or m