The query on record is missing help
Thanks in advancecreate the table TABLE_AA1
(
A NUMBER,
PLEASE THE NUMBER,
NUMBER OF END,
NUMBER OF TEACHER,
AVERAGE NUMBER,
THE REGION NUMBER
)
;
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (1, 0,.1, 159, 159, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (159, 168, 1 2,.1,.2,);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (3,.2,.3, 179, 159, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (4,.1,.2,, 250, 300, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (5,.2,.3, 320, 250, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (6,.3,.4,, 250, 380, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (7,.2,.3, 388, 379, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (8,.3,.4,, 379, 388, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (9,.4,.5, 388, 400, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (10, 499, 500, 1 1.5,.6,);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (11,.5,.6, 420, 448, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (12,.6,.7, 520, 530, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (13,.7,.8, 540, 550, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (14,.9, 1, 560, 570, 1);
commit;
I have a situation like below
(1) following query will display the calculation for the first 3 lines - works fine
(2) if the user pass parameter to eliminate the A = 2 & R_SQUARE = 0.95 and to calculate for the first 3 lines - works fine
(3) I have a problemn is so user pass the parameter for A = 2
I want to display eliminate an A = 2 & and R_SQUARE = 0.95 in the second query (as a part of the first 3 rows)
(No idea or help is appreciated)
I want the results of the query as below
A BEG END PROF AVERAGE REGION RN RN_DESC R_SQUARE R_SQUARE_VAL RANK
1 0 0.1 159 159 1 1 13 0.956274596 2
*2 0.1 0.2 159 168 1
3 0.2 0.3 179 159 1 2 12 0.956274596 2
4 0.1 0.2 250 300 1 3 11 0.956274596 0.956274596 2
5 0.2 0.3 320 250 1 4 10 0.018818382 1
6 0.3 0.4 250 380 1 5 9 0.018818382 1
7 0.2 0.3 388 379 1 6 8 0.018818382 0.018818382 1
(1) first query works FineSELECT d.*,DENSE_RANK() OVER (/*PARTITION BY r_square_val*10*/ ORDER BY R_SQUARE_VAL) RANK
FROM (SELECT c.*, last_value(r_square ignore nulls) over (order by rn_desc) r_square_val
FROM (SELECT a.*,
REGR_R2 (average, prof) OVER (ORDER BY rn
ROWS BETWEEN CASE WHEN MOD (rn, 3) = 0
THEN 3
WHEN rn_desc = 1
THEN MOD (rn, 3)
ELSE 0
END PRECEDING
AND CURRENT ROW) AS r_square
FROM (select b.*,
row_number() over (partition by region order by b.a) rn,
row_number() over (partition by region order by b.a desc) rn_desc
from table_aa1 b
/*where b.a != 2*/
) a) c) d
/*where trunc(r_square_val, 2) = 0.01*/
ORDER BY d.region asc ,d.a asc;
A BEG END PROF AVERAGE REGION RN RN_DESC R_SQUARE R_SQUARE_VAL RANK
-------------------------------------------------------------------------------------------------------
1 0 0.1 159 159 1 1 14 0.25 3
2 0.1 0.2 159 168 1 2 13 0.25 3
3 0.2 0.3 179 159 1 3 12 0.25 0.25 3
4 0.1 0.2 250 300 1 4 11 0.164520715 1
5 0.2 0.3 320 250 1 5 10 0.164520715 1
6 0.3 0.4 250 380 1 6 9 0.164520715 0.164520715 1
7 0.2 0.3 388 379 1 7 8 0.218256852 2
8 0.3 0.4 379 388 1 8 7 0.218256852 2
9 0.4 0.5 388 400 1 9 6 0.218256852 0.218256852 2
10 1.5 0.6 499 500 1 10 5 0.973538061 4
11 0.5 0.6 420 448 1 11 4 0.973538061 4
12 0.6 0.7 520 530 1 12 3 0.973538061 0.973538061 4
13 0.7 0.8 540 550 1 13 2 1 5
14 0.9 1 560 570 1 14 1 1 1 5
(2) request works very wellIf the user pass parameter to remove the A = 2 and R_SQUARE = 0.95 calculate for the first 3 lines - works fine
SELECT d.*,DENSE_RANK() OVER (/*PARTITION BY r_square_val*10*/ ORDER BY R_SQUARE_VAL) RANK
FROM (SELECT c.*, last_value(r_square ignore nulls) over (order by rn_desc) r_square_val
FROM (SELECT a.*,
REGR_R2 (average, prof) OVER (ORDER BY rn
ROWS BETWEEN CASE WHEN MOD (rn, 3) = 0
THEN 3
WHEN rn_desc = 1
THEN MOD (rn, 3)
ELSE 0
END PRECEDING
AND CURRENT ROW) AS r_square
FROM (select b.*,
row_number() over (partition by region order by b.a) rn,
row_number() over (partition by region order by b.a desc) rn_desc
from table_aa1 b
where b.a != 2
) a) c) d
where trunc(r_square_val, 2) <= 0.95
ORDER BY d.region asc ,d.a asc;
A BEG END PROF AVERAGE REGION RN RN_DESC R_SQUARE R_SQUARE_VAL RANK
1 0 0.1 159 159 1 1 13 0.956274596 2
3 0.2 0.3 179 159 1 2 12 0.956274596 2
4 0.1 0.2 250 300 1 3 11 0.956274596 0.956274596 2
5 0.2 0.3 320 250 1 4 10 0.018818382 1
6 0.3 0.4 250 380 1 5 9 0.018818382 1
7 0.2 0.3 388 379 1 6 8 0.018818382 0.018818382 1
Published by: user1849 on September 8, 2009 09:02Published by: user1849 on September 8, 2009 09:14
Published by: user1849 on September 8, 2009 09:17
You don't think the my last request everything works very well for your needs:
Look carefully
with req_data as
(
SELECT
d.*
, DENSE_RANK() OVER (ORDER BY R_SQUARE_VAL) RANK
FROM
(SELECT
c.*
, last_value(r_square ignore nulls) over (order by rn_desc) r_square_val
FROM
(SELECT
a.*
, REGR_R2 (average, prof) OVER (ORDER BY rn ROWS BETWEEN
CASE WHEN MOD (rn, 3) = 0 THEN 3
WHEN rn_desc = 1 THEN MOD (rn, 3)
ELSE 0
END PRECEDING
AND CURRENT ROW) AS r_square
FROM
(select
b.*
, row_number() over (partition by region order by b.a) rn
, row_number() over (partition by region order by b.a desc) rn_desc
from
table_aa1 b
where
b.a not in (select d.a from table_aa1 d where d.a in(2,6))) a
) c
) d
where
trunc(r_square_val, 2) <= 0.49
)
select
*
from
(
select
*
from
req_data
union all
select
m.*
, to_number(null) r_square
, to_number(null) r_square_val
, to_number(null) RANK
from
(
select
b.*
, row_number() over (partition by region order by b.a) rn
, row_number() over (partition by region order by b.a desc) rn_desc
from
table_aa1 b
) m
where m.a in (2, 6)
and exists
(select
1
from
(select
max(r.a) mx
, min(r.a) mn
from
req_data r
)
where
m.a between mn and mx
)
) x
ORDER BY
x.region asc
, x.a asc;
As a result of output product
5 0.2 0.3 320 250 1 4 9 0.496965785 1
6 0.3 0.4 250 380 1
7 0.2 0.3 388 379 1 5 8 0.496965785 1
8 0.3 0.4 379 388 1 6 7 0.496965785 0.496965785 1
Kind regards
Amit
Tags: Database
Similar Questions
-
When no rows returned in the query loop, replace Null - need help
Hello
I have a requirement where I have a request in the loop for and based on the results of the query, I do some operations.
But even if the query does not match, I should get back something like 'No Data'.
My loop is:
FOR V_SL IN)
SELECT ID, CATEGORY, DI_CD, REV_CD, SL_ID
OF SB, SLOT_2001 S2 SLOT_DATA WHERE
PBM BENEFIT_ID = S2. BENEFIT_ID AND
REV_CD = IN_REV_CD AND
(PROC_CD IS NULL OR PROC_CD = IN_PROC_CD)
ORDER OF DIAGCODE, PROCEDURECODE)
LOOP
END LOOP;
I do some operations inside the loop for. I want the loop to run even if the query returns no rows.
Can someone help me out here.
Thank you
RambeauFrank. I am really surprised to see this coming from you. A slider to not find all the lines loop does not cause an exception no_data_found.
-
Updated content item highlight when execute the query returns records to prevent
Hello
I use form 10g and I was wondering if it is possible to achieve the effect shows:
The performance of a query for a block of data in data table, the content / the value of the first element in the first record returned is always highlighted. Is it possible to prevent this highlighting, and simply place the focus of the cursor on the 'start' of the field before the first character of the value of the element. Thanks in advance for any suggestions,
Kind regards
Kevin.Keep the position of the cursor to Yes Dungeon.
Right after the call to the build-in execute_query try a synchronization; -
change / stop the query using bad plan
I use 11.2.0.3. I'm wrong a script with multiple insert into... Select. One of the insert running for hours because it is using bad plan because of State statistics. I've now updated the statistics. Is - it there anyway I can do oracle raise this insert or ignore this insert and continue with the other inserts in my script. (I don't want to kill the session, I want to run other sqls).
Also, for the future is there a way to make oracle dynamic sampling rather than obsolete statistics usage?
I was able to cancel the query in another session to help
exec
DBMS_RESOURCE_MANAGER.SWITCH_CONSUMER_GROUP_FOR_SESS (sid, serial#, 'CANCEL_SQL');
-
Help with the query to select only one record from the result set in double
Hello
Please help with the query. Version of Oracle database we use is 10g R2.
I have a vision that is duplicated IDS, but they are used across the different functions. See below examples of data. Please help me with a query to select only one record (based on ID regardless of the area) from the bottom of the result set of duplicate records. For what is the point of view is there unique records, given the combination of the fields ID, Org, DF, dry, Sub-Sec
ID Org DF Sec Sub-Sec (163) CQ CPDM CPDM HD (163) PC ENG ENG ENG (163) CQ ASIC ASIC IS 8888 TS TAC TAC TAC (163) TS HE HE SW 6789 CQ INFO INFO FOS 6789 PC SECSYS SECSYS INFO1 6789 TS SECSYS SECSYS INFO2 9009 PC BMS BMS BMS1 My result set must eliminate the duplicate identifiers regardless of whoever we choose of the result set. (I mean without distinction Org, DF, s, Sub-s). My expected result set should be.
ID DSB DF SEC Sub-Sec (163) CQ CPDM CPDM HD 8888 TS TAC TAC TAC 6789 CQ INFO INFO FOS 9009 PC BMS BMS BMS1 Thank you
Orton
Hello
This sounds like a job for ROW_NUMBER:
WITH got_r_num AS
(
SELECT id, DSB, df, s, sub_sec org
ROW_NUMBER () OVER (PARTITION BY ID.
ORDER BY org
) AS r_num
OF view_x
)
SELECT id, DSB, df, sub_sec s,
OF got_r_num
WHERE r_num = 1
;
He is a Top - N query example, where you choose the elements of N (N = 1 in this case) from the top of an ordered list.
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and INSERT, only relevant columns instructions) to your sample data and the results desired from these data. (I know that you said that you were a view selection. Just for this thread, pretending it is a picture and post simple CREATE TABLE and INSERT statements to simulate your point of view).
Point where the above query is to produce erroneous results, and explain, using specific examples, how you get the right results from data provided in these places. (I didn't quite understand the explanation above. I don't know why you want toID ORG DF DRY SUB_SEC
-- --- -- --- -------
1234 CQ DPRK DPRK HD
and is not
1234 IS CQ ASIC, ASIC
or
TS 1234 IT IT SW
or
1234 CQ ASIC ASIC HD
)
If you change the query at all, post your modified version.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).See the FAQ forum: https://forums.oracle.com/message/9362002
-
Need help to write a MySQL query that returns only the peer matching records
Because I don't know how to explain it easily, I use the table below as an example.
I want to create a MySQL query that returns only the records that match counterparts where 'col1' = 'ABC '.
Notice the ' ABC / GHI' record does not have a Counter-match ' GHI / ABC' record. This record must not be returned because there is no Counter-Party correspondent. With this table, the ' ABC / GHI' record should be the one returned in the query.
How can I create a query that will do it?
ID | col1 | col2
--------------------
1. ABC | DEF
2. DEF | ABC
3. ABC | IGS
4. DEF | IGS
5. IGS | DEF
* Please let me know if you have no idea of what I'm trying to explain.I wanted to just the results where col1 = ABC, but I already got the answer I needed on another forum. Thank you anyway.
SELECT a.col1,
a.col2
FROM table_name AS a
LEFT OUTER
Table_name JOIN b
ON b.col1 = a.col2
AND a.col1 = b.col2
WHERE b.col1 IS NOT NULL AND a.col1 = 'ABC '. -
Helps with the exclusion of the query items
I compare two identical tables between databases using the links to the db and I'm having issues getting my correct join show lines that exist in a table and not the other. The purpose of the request is to view the items that exist in one but not the other and where the value is different between the elements. The Grp, layer and Name columns are PKs.
So take the following data:
The result of the query should be:DB1 Grp Name Layer Value Alpha Key_One ModA 1 Beta Key_Two ModA 1 Gamma Key_Three ModB 0 Delta Key_Four ModA True Epsilon Key_Five ModB Hat Zeta Key_Six ModB Red DB2 Grp Name Layer Value Alpha Key_One ModA 0 Beta Key_Two ModA 1 Gamma Key_Three ModB 0 Delta Key_Four ModA False Epsilon Key_Five ModA Hat Eta Key_Seven ModB 0
I've been able to get the query to pull the differences when the record exists in both tables, but were not able to get when recording exists only in a single table. If it's important, I'm on 10.2.0.4.Grp Name Layer DB1.Value DB2.Value Alpha Key_One ModA 1 0 Delta Key_Four ModA True False Epsilon Key_Five ModA Hat Epsilon Key_Five ModB Hat Zeta Key_Six ModB Red Eta Key_Seven ModB 0
After the implementation of the above, I can run the following script which returns all but I want to exclude records where they correspond, in the example above, are GRPs beta and Gamma.CREATE TABLE tab1 (grp VARCHAR2 (10), nm VARCHAR2 (15), layer VARCHAR2 (4), rec_value VARCHAR2 (10)); CREATE TABLE tab2 (grp VARCHAR2 (10), nm VARCHAR2 (15), layer VARCHAR2 (4), rec_value VARCHAR2 (10)); INSERT INTO tab1 VALUES ('Alpha', 'Key_One', 'ModA', '1'); INSERT INTO tab1 VALUES ('Beta', 'Key_Two', 'ModA', '1'); INSERT INTO tab1 VALUES ('Gamma', 'Key_Three', 'ModB', '0'); INSERT INTO tab1 VALUES ('Delta', 'Key_Four', 'ModA', 'True'); INSERT INTO tab1 VALUES ('Epsilon', 'Key_Five', 'ModB', 'Hat'); INSERT INTO tab1 VALUES ('Zeta', 'Key_Six', 'ModB', 'Red'); INSERT INTO tab2 VALUES ('Alpha', 'Key_One', 'ModA', '0'); INSERT INTO tab2 VALUES ('Beta', 'Key_Two', 'ModA', '1'); INSERT INTO tab2 VALUES ('Gamma', 'Key_Three', 'ModB', '0'); INSERT INTO tab2 VALUES ('Delta', 'Key_Four', 'ModA', 'False'); INSERT INTO tab2 VALUES ('Epsilon', 'Key_Five', 'ModA', 'Hat'); INSERT INTO tab2 VALUES ('Eta', 'Key_Seven', 'ModB', '0'); COMMIT;
Any help would be appreciated.SELECT NVL (tab1.grp, tab2.grp) grp, NVL (tab1.nm, tab2.nm) nm, NVL (tab1.layer, tab2.layer) layer, tab1.rec_value tab1_value, tab2.rec_value tab2_value FROM tab1 FULL OUTER JOIN tab2 ON tab1.grp = tab2.grp AND tab1.nm = tab2.nm AND tab1.layer = tab2.layer ORDER BY 1,2,3; GRP NM LAYER TAB1_VALUE TAB2_VALUE ---------- --------------- ----- ---------- ---------- Alpha Key_One ModA 1 0 Beta Key_Two ModA 1 1 Delta Key_Four ModA True False Epsilon Key_Five ModA Hat Epsilon Key_Five ModB Hat Eta Key_Seven ModB 0 Gamma Key_Three ModB 0 0 Zeta Key_Six ModB Red 8 rows selected.
Hello
Just add a WHERE clause that makes tab1.rec_value and tab_2.rec_value are different, accounting for NULL values. (The only change I made to your application, in addition to the formatting, was to add a WHERE clause).
If rec_value may not actually be NULL:SELECT NVL (tab1.grp, tab2.grp) grp , NVL (tab1.nm, tab2.nm) nm , NVL (tab1.layer, tab2.layer) layer , tab1.rec_value tab1_value , tab2.rec_value tab2_value FROM tab1 FULL OUTER JOIN tab2 ON tab1.grp = tab2.grp AND tab1.nm = tab2.nm AND tab1.layer = tab2.layer WHERE DECODE ( tab1.rec_value , tab2.rec_value, 1 , 0 ) = 0 ORDER BY 1,2,3;
If rec_value can be null, we must distinguish between the ranks, which is NULL because he wasn't match (and therefore should be included) and the lines where the two are really NULL (and therefore, should not be displayed).
If one of the columns used to join the tables is NULL, the row is missing in one of the tables, and so forge displayed regardless of whether the rec_values is, so we can add a condtion to the WHERE clause:SELECT NVL (tab1.grp, tab2.grp) grp , NVL (tab1.nm, tab2.nm) nm , NVL (tab1.layer, tab2.layer) layer , tab1.rec_value tab1_value , tab2.rec_value tab2_value FROM tab1 FULL OUTER JOIN tab2 ON tab1.grp = tab2.grp AND tab1.nm = tab2.nm AND tab1.layer = tab2.layer WHERE DECODE ( tab1.rec_value , tab2.rec_value, 1 , 0 ) = 0 OR LEAST (tab1.grp, tab2.grp) IS NULL ORDER BY 1,2,3;
To test this, I added these 3 rows to the data:
INSERT INTO tab1 VALUES ('Theta', 'Key_Seven', 'ModB', NULL); INSERT INTO tab2 VALUES ('Theta', 'Key_Seven', 'ModB', NULL); INSERT INTO tab2 VALUES ('Iota', 'Key_Seven', 'ModB', NULL);
GRP = "Theta" should appear not, because the lines are identical in both tables.
GRP = 'Iota' should be displayed, because it is present only in tab2. -
drive is Matshita DVD-RAM UJ-850 s a SATA drive
I use windows Vista
Driver provider Microsoft
Day 21/06/2006
Version 6.0.6002.18005
Hello
Code 39 means that the driver is corrupted or missing.
Please make all below even if you have done some before as it is often the set of operations which solves
the question.Try this - Panel - Device Manager - CD/DVD - double-click on the device - driver tab - click
Update the drivers (this will probably do nothing) - then RIGHT click the drive - UNINSTALL - REBOOT
This will refresh the default driver stack. Even if the reader does not appear to continue below.
Then, work your way through these - don't forget the drive might be bad, could be a loose cable or
slight corrosion on the contacts (usually for a laptop) and other issues.Your CD or DVD drive is missing or is not recognized by Windows or other programs
http://support.microsoft.com/kb/314060 - a Mr FixitTry this fix manually if the Fixit 314060 does not work
http://www.pchell.com/hardware/cd_drive_error_code_39.shtmlYour CD or DVD drive is missing or is not recognized by Windows or other programs-
a Mr Fixit
http://support.Microsoft.com/kb/982116The CD drive or the DVD drive does not work as expected on a computer that you upgraded to Windows Vista
http://support.Microsoft.com/kb/929461When you insert a CD or a DVD, Windows Vista may not recognize the disc
http://support.Microsoft.com/kb/939052Your CD or DVD drive cannot read or write media - A Mr Fixit
http://support.Microsoft.com/GP/cd_dvd_drive_problemsCD/DVD drive does not appear in Windows Vista, or you receive this error during the installation of Windows Vista after booting from the DVD (AHCI)
http://support.Microsoft.com/kb/952951
Drive CD - R or CD - RW Drive is not recognized as a recordable device
http://support.Microsoft.com/kb/316529/Hardware devices not detected or not working - A Mr Fixit
http://support.Microsoft.com/GP/hardware_device_problemsAnother possibility is that the cables are loose. Remove ALL power, then make sure that the cables in both
ends. Remove and replace, do not just tight. For laptops, you can often clean power and
contacts data with a pencil eraser.--------------------------------------------------------------
Also check with your system manufacturer to see if there are any updated drivers for your DVD. Or even if it
are you can reinstall the 'old'. Many use Windows default drivers however some special aura
ones. Also check the website of the manufacturer of the car.Look at the sites of the manufacturer for drivers - and the manufacturer of the device manually.
http://pcsupport.about.com/od/driverssupport/HT/driverdlmfgr.htmI hope this helps.
Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle="">-><- mark="" twain="" said="" it="">->
-
Windows 7 boot CD system recovery cannot fix the Master Boot Record is damaged or missing?
This question is on the drive that Windows 7 users can make by going to the backup and restore > create a system repair disc, and then burn the disc.
Windows says that this disk can be used to start the computer. However, you will not necessarily be able to boot your Windows 7 operating system from the hard drive. When I had a problem recently (shut down system and on reboot I got a message BACK that says "Boot MGR missing") this disc is not to try to do a repair. In the system recovery Menu, you see here when you start the CD:
I chose "Startup Repair" and he couldn't fix anything. I ended up cloning of my hard disk from a backup.
Of http://windows.microsoft.com/en-us/windows/startup-repair-faq#1TC=windows-7
"Are there problems that Startup Repair cannot fix?
Startup Repair can only fix certain problems, such as missing or damaged system files. He can't fix the failures of hardware, such as a failing hard disk or incompatible memory, nor it protects against virus attacks.
Startup Repair is not designed to fix Windows installation problems, is not a backup tool, so it cannot help you recover personal files, such as photos or documents. To help protect your computer, back up your system and your files regularly. For more information, search for "backup" in Windows Help and Support. »
So here's my question: how to create a bootable CD that has everything you need to fix the Master Boot Record, whereas in case your startup files are damaged, altered, or deleted (and of course, you can not start your system from the hard drive) it will be either fix the files on the hard disk or at least still start your operating system on your hard drive?
To answer my own question (which becomes a habit on this forum): http://www.sevenforums.com/tutorials/20864-mbr-restore-windows-7-master-boot-record.html
It turns out that the repair CD Windows 7 Sytem that I had done was the right tool for the job but I didn't know how to use it. The above link explains how to use the command prompt window to repair the boot record.
Other advice, I had was to have used the "Startup Repair" option in the Tools menu of recovery after launching the repair CD, but then he runs three times. For some reason, it takes three times to run before it can solve the problem. I think that the command prompt window method is probably more reliable.
-
Hello
Could someone please help how to tune the query as its takes a long time to retrieve the results.
Select
col1,
col2,
col3,
COL4,
col5,
col6,
col7,
COL8,
col9,
col10,
Col11,
col12,
Sum (volume1),
Sum (volume2),
Sum (volume3),
Sum (volume4),
Sum (volume5),
Sum (volume6),
Sum (volume7),
Sum (volume8),
Sum (volume9),
Sum (volume10),
Sum (volume11),
Sum (volume12),
Sum (volume13),
Sum (volume14),
Sum (volume15),
Sum (volume16),
Sum (volume17),
Sum (Volume18),
Sum (volume19),
Sum (volume20),
Sum (rate1),
Sum (rate2),
Sum (rate3),
Sum (rate4),
Sum (rate5),
Sum (rate6),
Sum (rate7),
Sum (rate8),
Sum (rate9),
Sum (rate10),
Sum (rate11),
Sum (rate12),
Sum (rate13),
Sum (rate14),
Sum (rate15),
Sum (rate16),
Sum (rate17),
Sum (rate18)
Sum (rate19),
Sum (rate20)
Of
Table 1 - 13, 25, 99, 400 records
Table2 - 13, 45, 1000 records
Table 3 - 4, 50, 000 records
Table 4 - 1,00,000 records
table5 - 30 000 records
where tabl1.col1 = table2.col2,
Table1.Col1 = table3.col1.
table2.col2 = table3.col2...
Group
Sum (volume1),
Sum (volume2),
Sum (volume3),
Sum (volume4),
Sum (volume5),
Sum (volume6),
Sum (volume7),
Sum (volume8),
Sum (volume9),
Sum (volume10),
Sum (volume11),
Sum (volume12),
Sum (volume13),
Sum (volume14),
Sum (volume15),
Sum (volume16),
Sum (volume17),
Sum (Volume18),
Sum (volume19),
Sum (volume20),
Sum (rate1),
Sum (rate2),
Sum (rate3),
Sum (rate4),
Sum (rate5),
Sum (rate6),
Sum (rate7),
Sum (rate8),
Sum (rate9),
Sum (rate10),
Sum (rate11),
Sum (rate12),
Sum (rate13),
Sum (rate14),
Sum (rate15),
Sum (rate16),
Sum (rate17),
Sum (rate18)
Sum (rate19),
Sum (rate20)
Thank you
Prasad.
> Could someone please help how to tune the query as its takes a long time to retrieve the results.
The query you posted is obviously fake.
If you ask to give us a request that you do not post and we cannot see.
For real?
-
Need help to understand the query result
Hi gurus
I was reading one of the question here in this forum and its link is below:
I had some confusion related to this code and don't understand the logic of the out put, see query below:
Query
with sub_services as
(
Select su_seq 12323, 'HLR1' so_id, 1 seq Union double all the
Select su_seq 12323, "HLR2' so_id, seq 2 Union double all the
Select su_seq 12323, "A09" so_id, seq 3 of all the double union
Select su_seq 12333, "MO1" so_id, seq 4 Union double all the
Select su_seq 12333, "MO2' so_id, seq 5 Union double all the
Select su_seq 12333, "A09" so_id, 6 seq in union double all the
Select su_seq 12333, 'M0CR' so_id, seq 7 Union double all the
Select su_seq 12999, "LOL1' so_id, seq 8 Union double all the
Select su_seq 12999, "LOL2' so_id, seq 9 double
)
Select *.
of sub_services b
where exists (select 1 from sub_services
where su_seq = b.su_seq
and so_id = 'A09.
)
order by 2;
The query result
12323 A09 3
12333 6 A09
12323 HLR1 1
12323 HLR2 2
12333 M0CR 7
12333 4 MO1
12333 5 MO2
According to my understanding, the above query should return records in red only because of her is below command
It exists (select 1 from sub_services
where su_seq = b.su_seq
and so_id = 'A09.
but don't know why he's back 7 files, can someone help me understand the result...
It is query is functionally identical to the PL/SQL block, but much more effective.
declare
number of l_res;
Start
for line (select *)
sub_services) loop
Start
Select 1 from l_res
of sub_services
where su_seq = row.su_seq and
so_id = "A09" and
rownum = 1;
Essentially every row in the outer query are tested against him exists query. Given the correlation between two requests is based only on su_seq each line with a su_seq value returned by him is returned in the output.
Another way to think he uses instead a join condition. This query is equivalent to the query to exist
Select the main
of main sub_services
Join select (separate su_seq
of sub_services
where so_id = "A09") cond
We main.su_seq = cond.su_seq;
John
-
Build the query in PLSQL to return well formed XML with multiple records
Hello
It's very urgent. I am creating a PLSQL query who must retrieve all records in the table of "tbl_Emp" oracle database in a well-formed xml format. The format is given below
* < employees xmlns = "http://App.Schemas.Employees" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" > *.
* < employee > *.
* < name > < / name >. *
* < Last_Name > < / Last_Name > *.
* < / employee > *.
* < employee > *.
* < name > < / name >. *
* < Last_Name > < / Last_Name > *.
* < / employee > *.
*...*
* < / employees > *.
To retrieve data in above format, I tried to create a query for a long time as below
SELECT XMLElement ('employees',
XMLAttributes ('http://App.Schemas.Employees' AS 'xmlns',
(* "http://www.w3.org/2001/XMLSchema-instance" AS "xmlns: xsi"), *.
XMLElement ("employee", XMLForest (First_Name, Last_Name)))
AS 'RESULT '.
OF tbl_Emp;
But it does not give me the desired output. It creates the < Employees > tag with each individual record which I didn't need. I need tag < Employees > the root tag and the tag < employee > repeat and wrap each individual record. Please help me in that it's very urgent. Thank you.Hello
Remember that nothing is 'urgent' here, and repeating it will probably produce the opposite effect.
If you need a quick answer, provide all necessary details, in the first place:
-version of db
-test with sample data and DDL casesThat being said, it's easy, it takes group using XMLAgg:
SELECT XMLElement("Employees" , XMLAttributes( 'http://App.Schemas.Employees' AS "xmlns" , 'http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi" ) , XMLAgg( XMLElement("Employee" , XMLForest( e.first_name as "First_Name" , e.last_name as "Last_Name" ) ) ) ) AS "RESULT" FROM hr.employees e ;
-
Is Oracle and all the records in the query
Hello
I have a problem with Oracle forms of performance. In the block of my list, I want to see about 2,000,000 records. Under this block list, there is a field 3 with text-to-speech function, so I have to "ask all records. When I run my application, I get error FRM-41839. When I recive on 2,000 records everything is OK.
Can I use the size of table query or the number of buffered property records?
Please help me.
Sorry for my bad English.Instead of setting "Question everything", you might try "Summaries Precompute" set to Yes
-
Place the missing documents in the list of records with a rank value
Hi all
I have this table:
And I need to return the same results but with the addition of records that have no rank. For new records the VALUE must always be zero (0) and the value of DATA_INI must have the same value as the order of the records immediately following. Just like that:WITH taba AS (SELECT 99 AS id, '2011-08-08' AS date_ini, 10 AS VALUE, 1 AS RANK FROM DUAL UNION ALL SELECT 99 AS id, '2011-09-08' AS date_ini, 11 AS VALUE, 2 AS RANK FROM DUAL UNION ALL SELECT 99 AS id, '2011-10-08' AS date_ini, 10 AS VALUE, 4 AS RANK FROM DUAL UNION ALL SELECT 999 AS id, '2011-08-08' AS date_ini, 10 AS VALUE, 1 AS RANK FROM DUAL UNION ALL SELECT 999 AS id, '2011-09-08' AS date_ini, 10 AS VALUE, 2 AS RANK FROM DUAL UNION ALL SELECT 999 AS id, '2011-10-08' AS date_ini, 10 AS VALUE, 3 AS RANK FROM DUAL UNION ALL SELECT 9999 AS id, '2011-08-08' AS date_ini, 10 AS VALUE, 2 AS RANK FROM DUAL UNION ALL SELECT 9999 AS id, '2011-09-08' AS date_ini, 15 AS VALUE, 3 AS RANK FROM DUAL UNION ALL SELECT 9999 AS id, '2011-10-08' AS date_ini, 10 AS VALUE, 4 AS RANK FROM DUAL) SELECT * FROM taba
I can do this using a loop procedure, but I want a filter query. ;)99 2011-08-08 10 1 99 2011-09-08 11 2 *99 2011-10-08 0 3* 99 2011-10-08 10 4 999 2011-08-08 10 1 999 2011-09-08 10 2 999 2011-10-08 10 3 *9999 2011-08-08 0 1* 9999 2011-08-08 10 2 9999 2011-09-08 15 3 9999 2011-10-08 10 4
Thanks in advance.
Filipe AlmeidaHi, Felipe,.
So, you want multiple copies of a few lines. In other words, if a value or rnk (RANK is not a column name right) is missing in a given id you want to with the next highest rnk and the same id line repeated 2 or maybe even several times. All copies will be identical, except that rnk will have the missing numbers, and the value will be 0 on all additional copies.
A way to do that is to join your table (or something very similar to it, as in the example below) to a Meter of Table , which is a table (or a result set, in this example) counts 1, 2, 3,... up to however many copies may be required.
WITH got_rows_needed AS ( SELECT id, date_ini, value, rnk , rnk - LAG (rnk, 1, 0) OVER ( PARTITION BY id ORDER BY rnk ) AS rows_needed FROM taba ) , cntr AS ( SELECT LEVEL - 1 AS n FROM ( SELECT MAX (rows_needed) AS max_rows_needed FROM got_rows_needed ) CONNECT BY LEVEL <= max_rows_needed ) SELECT r.id , r.date_ini , CASE WHEN c.n = 0 THEN r.value ELSE 0 END AS value , r.rnk - c.n AS rnk FROM got_rows_needed r JOIN cntr c ON c.n < r.rows_needed ORDER BY id , rnk ;
By elsewhere, store date information in a VARCHAR2 column, such as date_ini, is a very bad idea. Use a DATE column.
Published by: Frank Kulash, August 8, 2012 11:02
RANK is a keyword from Oracle. (It is the name of a built-in function). If you specify your own columns of RANK, it will confuse people reading the code, and it can result in compiler errors, too.
ID is also an Oracle keyword. To be sure, you can use another name, such as grp_id, instead of id.
It is best not to name your own objects with any name of fArrondi in v$ reserrved_words.keyword. -
Need help in the optimization of the query with the Group and joins by clause
I'm having the problem by running the following query... It takes a lot of time. To simplify, I added the two tables FILE_STATUS = stores the file load details and COMM table Board table job showing records treated successfully and which was communicated to the other system real. Records with status = T is trasnmitted to another system and traansactions with P is waiting.
Here's the query I wrote to give me the details of the file that has been loaded into the system. He reads the table of State and the commission files to display the name of the file, total records loaded, total at the table of the commission and the number of records which has finally been passed successfully loaded (Status = T) with other systems.CREATE TABLE FILE_STATUS (FILE_ID VARCHAR2(14), FILE_NAME VARCHAR2(20), CARR_CD VARCHAR2(5), TOT_REC NUMBER, TOT_SUCC NUMBER); CREATE TABLE COMM (SRC_FILE_ID VARCHAR2(14), REC_ID NUMBER, STATUS CHAR(1)); INSERT INTO FILE_STATUS VALUES ('12345678', 'CM_LIBM.TXT', 'LIBM', 5, 4); INSERT INTO FILE_STATUS VALUES ('12345679', 'CM_HIPNT.TXT', 'HIPNT', 4, 0); INSERT INTO COMM VALUES ('12345678', 1, 'T'); INSERT INTO COMM VALUES ('12345678', 3, 'T'); INSERT INTO COMM VALUES ('12345678', 4, 'P'); INSERT INTO COMM VALUES ('12345678', 5, 'P'); COMMIT;
In production, this request has several joins and takes a long time to deal with... the main culprit for me is the join on the COMM table to count the number of number of transactions sent. Please can you give me tips to optimize this query to get results faster? What I need to delete the Group and use the partition or something else. Help, please!SELECT FS.CARR_CD ,FS.FILE_NAME ,FS.FILE_ID ,FS.TOT_REC ,FS.TOT_SUCC ,NVL(C.TOT_TRANS, 0) TOT_TRANS FROM FILE_STATUS FS LEFT JOIN ( SELECT SRC_FILE_ID, COUNT(*) TOT_TRANS FROM COMM WHERE STATUS = 'T' GROUP BY SRC_FILE_ID ) C ON C.SRC_FILE_ID = FS.FILE_ID WHERE FILE_ID = '12345678';
Don't know if it will be faster based on the information provided, but analytical functions offer an alternative approach;
select carr_cd, file_name, file_id, tot_rec, tot_succ, tot_trans from (select fs.carr_cd, fs.file_name, fs.file_id, fs.tot_rec, fs.tot_succ, count(case when c.status = 'T' then 1 else null end) over(partition by c.src_file_id) tot_trans, row_number() over(partition by c.src_file_id order by null) rn from file_status fs left join comm c on c.src_file_id = fs.file_id where file_id = '12345678') where rn = 1; CARR_CD FILE_NAME FILE_ID TOT_REC TOT_SUCC TOT_TRANS ------- -------------------- -------------- ---------- ---------- ---------- LIBM CM_LIBM.TXT 12345678 5 4 2
Maybe you are looking for
-
How can I use taskkill command in Windows XP Home Edition
HelloI need to use the taskkill command, but I have a Win XP Home. What can I do?THX
-
Pavilion 6500: I have a hp pavilion 6500 and no idea of what the admin password.
I have a hp pavilion 6500 windows vista 64-bit and asked an administrator password to market. of course we have no idea what this could be so we're stuck. the stop code we get is 14713. I would greatly appreciate any help we can get to get on the lap
-
WRTU54G-TM: switch does not connect
I have a WRTU54G-TM router that allows PCs to connect directly via its LAN ports without problem. However, whenever I connect to a switch, this switch does not have a good connection. I tried several different CAT5 cables and two switches. The two
-
HP 6100 on extended connection problem router wireless
We have two printers a 8600 while one and a new printer 6100. My Office I use a mac OSX Mavericks on the network SSID 'Outhouse' my wifes machine is in another building with the 6100 and the extended network SSID "outhouse_EXT". We both need to be a
-
How Casio CTK 710 USB MIDI keyboard work in Windows Vista?
Original title: Vista compatilbility issues How do you solve compatibility Vista to Casio CTK 710 USB MIDI keyboard?