To find the Top most parent SQL
How to find the top most parent SQL. I want to avoid the hierarchical query that shows a high cost to run. Please suggest alternative options to find the parent
Maybe (when having multiple hierarchy trees) to be adapted to your needs
Select empno, I
from (select empno, I
WCP
where empno = 7876
model
hierarchy of reference on (select employee empno,
Manager Mgr
WCP
)
dimension (employee)
measures (Manager)
main main_model
size of (0 I)
measures (empno)
rules iterate (100) until (empno [iteration_number + 1] is null)
(
EmpNo [iteration_number + 1] = hierarchy.manager [empno [iteration_number]]
)
)
where empno is not null
order by I desc
EMPNO | I |
---|---|
7839 | 3 |
7566 | 2 |
7788 | 1 |
7876 | 0 |
Concerning
Etbin
Tags: Database
Similar Questions
-
Find the top level of a VM folder
I want to find the name of the top-level folder that contains a virtual machine in a data center and looking for the root tree.
For example \\datacenter\folder1\folder2\folder3\TestVM
I try to find as a parameter of the TestVM folder1.
I need to sort all the VM in our sphere of their top-level folder
In all cases to do this would be appreciated.
Also it would be quite in powercli with scripts
Try something like this
$vm = Get-VM -Name TestVM$object = $vm.ExtensionData$parent = Get-View $object.Parent while($parent -is [VMware.Vim.Folder] -and $parent.Name -ne "vm"){ $object = $parent $parent = Get-View $object.Parent}$object | Select @{N="VM";E={$vm.Name}}, @{N="Top Folder";E={$object.Name}}
-
Find the top 3 travellers per year
Hello
I created a single table where I store the ID of the loyalty, road ID as well as the Dates of vol. I have 5 frequent flyers in total and only 2 channels (to keep this small and concise for this exercise). I'm hoping to find the big TOP 3 passenger flight annually.
The output should be as follows:
Script for tableFlight Year Route ID Frequent Flyer Flight Count ======================================================= 2005 001 1001 5 2005 001 1002 3 2005 001 1003 3 2005 002 1004 7 2005 002 1005 5 2005 002 1001 1 2006 001 1002 7 2006 001 1003 5 2006 001 1001 1 2006 002 1005 11 2006 002 1003 1 2006 002 1004 1
INSERT the Script for the tableCREATE TABLE FLIGHTS ( FREQ_FLYER_ID VARCHAR2(4), ROUTE_ID VARCHAR2(3), FLIGHT_DATE DATE );
Thanks in advance!-- 1001: 5; 1002: 3; 1003: 3; 1004: 1, 1005: 1 Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1001','001',to_date('01-JAN-05','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1001','001',to_date('01-FEB-05','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1001','001',to_date('01-MAR-05','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1001','001',to_date('01-APR-05','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1001','001',to_date('01-MAY-05','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1002','001',to_date('01-JAN-05','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1002','001',to_date('01-FEB-05','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1002','001',to_date('01-MAR-05','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1003','001',to_date('01-APR-05','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1003','001',to_date('01-MAY-05','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1003','001',to_date('01-JUN-05','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1004','001',to_date('01-FEB-05','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1005','001',to_date('01-MAR-05','DD-MON-RR')); -- 1001: 1; 1002: 0; 1003: 0, 1004: 7; 1005: 5 insert into flights (freq_flyer_id,route_id,flight_date) values ('1001','002',to_date('31-JAN-05','DD-MON-RR')); insert into flights (freq_flyer_id,route_id,flight_date) values ('1004','002',to_date('31-JAN-05','DD-MON-RR')); insert into flights (freq_flyer_id,route_id,flight_date) values ('1004','002',to_date('28-FEB-05','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1004','002',to_date('31-MAR-05','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1004','002',to_date('30-APR-05','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1004','002',to_date('31-MAY-05','DD-MON-RR')); insert into flights (freq_flyer_id,route_id,flight_date) values ('1004','002',to_date('30-JUN-05','DD-MON-RR')); insert into flights (freq_flyer_id,route_id,flight_date) values ('1004','002',to_date('31-JUL-05','DD-MON-RR')); insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('30-APR-05','DD-MON-RR')); insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('31-MAY-05','DD-MON-RR')); insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('30-JUN-05','DD-MON-RR')); insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('31-JUL-05','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1005','002',to_date('31-AUG-05','DD-MON-RR')); -- 1001: 1; 1002: 7; 1003: 5, 1004: 0; 1005: 0 insert into flights (freq_flyer_id,route_id,flight_date) values ('1001','001',to_date('01-JAN-06','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1002','001',to_date('01-FEB-06','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1002','001',to_date('01-MAR-06','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1002','001',to_date('01-APR-06','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1002','001',to_date('01-MAY-06','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1002','001',to_date('01-JUN-06','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1002','001',to_date('01-JUL-06','DD-MON-RR')); insert into flights (freq_flyer_id,route_id,flight_date) values ('1002','001',to_date('01-AUG-06','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1003','001',to_date('01-APR-06','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1003','001',to_date('01-MAY-06','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1003','001',to_date('01-JUN-06','DD-MON-RR')); insert into flights (freq_flyer_id,route_id,flight_date) values ('1003','001',to_date('01-JUL-06','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1003','001',to_date('01-AUG-06','DD-MON-RR')); -- 1001: 0; 1002: 0; 1003: 1, 1004: 1; 1005: 11 insert into flights (freq_flyer_id,route_id,flight_date) values ('1003','002',to_date('31-JAN-06','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1004','002',to_date('28-FEB-06','DD-MON-RR')); insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('31-JAN-06','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1005','002',to_date('28-FEB-06','DD-MON-RR')); insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('31-MAR-06','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1005','002',to_date('30-APR-06','DD-MON-RR')); insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('31-MAY-06','DD-MON-RR')); insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('30-JUN-06','DD-MON-RR')); insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('31-JUL-06','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1005','002',to_date('31-AUG-06','DD-MON-RR')); insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('30-SEP-06','DD-MON-RR')); insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('31-OCT-06','DD-MON-RR')); Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1005','002',to_date('30-NOV-06','DD-MON-RR'));
Hello
Here's one way:
WITH got_r_num AS ( SELECT EXTRACT (YEAR FROM TRUNC (flight_date, 'YEAR')) AS flight_year , route_id , freq_flyer_id , COUNT (*) AS flight_count , RANK () OVER ( PARTITION BY TRUNC (flight_date, 'YEAR') , route_id ORDER BY COUNT (*) DESC ) AS r_num FROM flights GROUP BY TRUNC (flight_date, 'YEAR') , route_id , freq_flyer_id ) SELECT * -- or list all columns except r_num FROM got_r_num WHERE r_num <= 3 ORDER BY flight_year , route_id , r_num ;
If there be a tie (in other words, if 4 or more people, some with exactly the same number of flights, all can to be in the top 3 for a given year and the road) then the above query will include all the contenders for the top 3. For example, if you add one more line of your sample data:
Insert into FLIGHTS (FREQ_FLYER_ID, ROUTE_ID, FLIGHT_DATE) values ('1009', '002', to_date('30-NOV-2006','DD-MON-YYYY'));
Now, who are the top 3 flliers for 2006 on road '002'? Obviously, "1005" is one of them, but there is a tie of 3 - way for second place: '1003 ', '1004' and ' 1009' have exactly 1 flight, and all have equal calim to be in the top 3. Why would you exclude one of them, ratehr than the other two? The query above includes all the.
If you want to ensure that not more than 3 rows are included for the whole year and the road, and then add the columns of tiebreaker to analytical ORDER BY clause and/or use ROW_NUMBER instead of RANK.This is called a Query Top - N , because you're gathering of N (N = 3 in this case) from the top of an ordered list.
Published by: Frank Kulash, December 17, 2012 12:52
-
Script to find the 'top 10' VMs consuming disk performance?
We're troubleshooting an issue of storage and I'm looking for a better way to find virtual machines that consume disk peformance. If I had a wish list, the script would be the 'top 10' VMs with the highest disk throughput and the e/s in the last 24 hours.
Such a script exist? Any help would be greatly appreciated.
You can try the following one liner
Get-VM | Select Name, @{N="AverageIO"; E={($_ | Get-Stat -Stat disk.usage.average -Start (Get-Date).adddays(-1) | Measure-Object -Average -Property Value).Average}} | ` Sort-Object -Property AverageIO -Descending | Select -First 10
This example uses the metric of disk.usage.average but you can easily use any of the other measures related to the disc.
____________
Blog: LucD notes
Twitter: lucd22
-
Where can I find the LOG of all sql
Is the a file where I can find a journal all the sql has to run on the database?
I want inside a sql query that causes an error, but what I have is an error message and I would find a file with all sql executed on a database instance.
Thank youYou know the date and time where the problem statement has been executed? If so, try this:
whole flax 10000
Select to_char (LAST_ACTIVE_TIME, ' ' HH24:MI:SS MON-DD-YYYY), SQL_FULLTEXT from v$ sql by LAST_ACTIVE_TIME; -
algorithm to find the top of the parabola
Use case: mower rejection of common-mode using a programmable potentiometer
Problem: The performance of each circuit varies greatly and you are looking for best value (lowest CMRR) gives erroneous results. The performance seems to be relatively flat on some circuits, straight on others. Launching in the middle range of the potentiometer and moving upwards or downwards, I compare the measured value after the change of the potentiometer to the last measured value. By doing this I can get for the lowest CMR.
Setup: entry wave sign 5V 60 Hz on both positive and negative of a differential ADC. The potentiometer is cut and reduces common-mode noise. Go away and the common-mode noise increases.
Question: I would like to use adjustment curve to calculate the shape of the performance of the CMR. Take several steps (no more than 10 then I hope). Get the x y (x = 0 to 1023 trim adjustment potentiometers, Y = amplitude of the measured signal common-mode). Find the vertex.
Is this possible and can someone point to an example. I have not found one.
A parable is a second order polynomial curve. The Summit must be the peak value. The general polynomial Fit.vi to maintain your data. The Coefficients of the polynomial outputs to calculate the location of the tip with a DAB of analytic geometry.
Edit: Note that you may need to do checks to make sure that your data has not generated any curve as a parable.
Lynn
-
to find the location of PL/SQL, stored PROCEDURE in the database
Hello
This is the detail I have the executable of the Application Developer program simultaneous
Executable NAPESCO_STAFF_LEDGER_DTLS
Short name NPSTALEDDTLS
Application of human resources
Execution of PL/SQL, stored procedure method
Name of file execution NAPESCO_STAFF_LEDGER_DTLS
I would like to know how to view and change this procedure, where it is stored
kindly helpHello
This seems to be a custom package. To display the source of the simultaneous program ' PL/SQL Stored Procedure', please refer to (Note: 455582.1 - where can I get the whole "stored procedure" Pl/Sql Source file on the current program?).
Thank you
Hussein -
Find the top level element in SQL
Hi all
I have a table with the following format. item_id, sup_item_id and a few other columns.
And that's the real problem:
We have parts (elements) mounted in designed, says let cars for example. also is it a tyre_1 element with car_A, car_B and car_C have entries in the table like this
item_id sup_item_id
tyre_1 car_A
tyre_1 car_B
tyre_1 car_C
but sometimes we are small element in someother element, then it goes to the main product. For example, we adjust wire_1 in circuit_1 which then goes to car_A and car_B. This number can have any levels and wire_1 can be in any number of circuits.
If the data table will be like this
item_id sup_item_id
wire_1 circuit_1
wire_1 circuit_2
circuit_1 car_A
circuit_1 car_B
You can identify high most of the elements in the table because they have no value in the sup_item_id field.
item_id sup_item_id
car_A
car_B
so, I want to write a sql to discover all the elements of highest level of the page for a given part. Can someone help me with this.I think that's what you're looking for
"Rim_1", I took as a point of entrywith data as ( select 'bolt_1' item_id,'rim_1' sup_item_id from dual union all select 'rim_1' item_id,'tyre_1' sup_item_id from dual union all select 'tyre_1' item_id,'frame_1' sup_item_id from dual union all select 'frame_1' item_id,'car_1' sup_item_id from dual union all select 'rim_1' item_id,'car_2' sup_item_id from dual union all select 'car_1' item_id,null sup_item_id from dual union all select 'car_2' item_id,null sup_item_id from dual ) select item_id from data where sup_item_id is null start with item_id = 'rim_1' connect by item_id = prior sup_item_id;
Thank you
Andy -
How to find the best log of SQL in the responses of the OBI?
While I have an error by a request of the OBI in answers page, the error message in the result tab is usually not very useful, as:
I then go to the Session Monitor and click the view log. By doing so, sometimes, I got the complete sql statement. It is good and I can understand the problems. Sometimes, I have things like:Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P:OI2DL65P State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 27005] Unresolved column: "Sales Facts Current Month"."Amount Sold (000) Current Month". (HY000) SQL Issued: {call NQSGetQueryColumnInfo('SELECT "Sales Facts Current Month"."Amount Sold (000) Current Month", "Sales Facts"."Amount Sold", Calendar."Calendar Month Desc", Calendar."Calendar Month Name", Products."Prod Category" FROM SH')} SQL Issued: SELECT "Sales Facts Current Month"."Amount Sold (000) Current Month", "Sales Facts"."Amount Sold", Calendar."Calendar Month Desc", Calendar."Calendar Month Name", Products."Prod Category" FROM SH
It is not enough that the selected tables are not entirely clear on. It appears like it find OBI the sql in the cache and process the request entirely.-------------------- SQL Request: SET VARIABLE QUERY_SRC_CD='Report',SAW_SRC_PATH='/shared/sh/Learn';SELECT Times."Calendar Month Name" saw_0, Times."Calendar Month Desc" saw_1, Products."Prod Category" saw_2, Salesfacts."Amount Sold" saw_3, REPORT_SUM(saw_3 BY saw_0, saw_1), REPORT_SUM(saw_3 BY ) FROM SH WHERE (TOPN(Times."Calendar Month Id",40) <= 40) AND (Channels."Channel Desc" = 'Direct Sales') ORDER BY saw_1, saw_0, saw_2 +++Administrator:13290000:1329000f:----2009/09/29 09:18:33 -------------------- General Query Info: Repository: Star, Subject Area: SH, Presentation: SH +++Administrator:13290000:1329000f:----2009/09/29 09:18:33 -------------------- Cache Hit on query: Matching Query: SET VARIABLE QUERY_SRC_CD='Report';SELECT Times."Calendar Month Name" saw_0, Times."Calendar Month Desc" saw_1, Products."Prod Category" saw_2, Salesfacts."Amount Sold" saw_3 FROM SH WHERE (TOPN(Times."Calendar Month Id",40) <= 40) AND (Channels."Channel Desc" = 'Direct Sales') ORDER BY saw_0, saw_1, saw_2 Created by: Administrator
Is there a way I can force return OBI demand? Is there a way to get OBI newspaper the complete sql statement? This way I can copy the SQL to SQL * more and find exactly the problem
Thank you.Physical SQL is not visible because it hits the cache.
You can:
(1) clear RPD physical cache and run the query again.
or
(2) copy the SQL logic, go to web Admin - number SQL - paste the SQL logic, then just change a setting or two, so it does not hit the cache. For example, to change a filter to Jan Feb... or just add a dummy column initially as select 1 or select 'a'... .rest of sql even.in this way, you can avoid hitting the cache and see the sql code (at the bottom of the results - view the journal)
Make sure that you have enabled the option to cache presentation server and define the level of logging to 4 or more to see the details.
HTH
-
How to find the sid, serial # for sql in v$ sqlarea
Hello
10 gr 2
in order to dig the session that runs particular sql
say querying v$ sqlarea and get sql_id
now how to map at the session of v$Look at the v$ active_session_history and dba_hist_sqltext and you should be able to find what you are looking for, if you have the possibility of using these views.
-
Tips to find the "top talkers" on Cisco ASA
Y at - it a command that displays the users that use the most bandwidth? Or I need a 3rd party app that monitors the pipe? I basically am noticing a spike in bandwidth consumption from time to time and have no way to easily identify the culprit. Any suggestions would be greatly appreciated.
Jeff
Apart from the typical SSL the ASDM had a major overhaul. It now includes a firewall dashboard where you can see rules for superior access, services, hosts etc.
-
DENSE_RANK and find the top three rows return regardless of their rank.
Oracle Database 10 g Express Edition Release 10.2.0.1.0 - product
Hello
I have the following problem;
Dense_rank using I've categorized the trees in a plot of height.
Now I need to filter the first three records by parcel based on the position of the trees, it's complicated by the fact that sometimes two or three of the three tallest trees have the same height.
Records that I want to use for the parcel number 90001 are tree numbers 4, 5 and 3.
Records that I want to use for the parcel number 31000 are tree numbers 4, 5, and 3, but rather the number 2 shaft is included.
The dense rank function allows me to classify the trees, but then it has accomplished its purpose. The following query is an example of what I want to do - but - I need to access the 3 early accounts after the rankings were made, so the following query is not going to use the collation.select distinct plot_number , tree_number , tree_height , dense_rank() over (partition by plot_number order by tree_height desc)ht_rank from tst_rank order by plot_number, ht_rank asc ; PLOT_NUMBER TREE_NUMBER TREE_HEIGHT HT_RANK ----------- ----------- ----------- ------- 31000 4 10 1 31000 5 10 1 31000 3 3 2 31000 2 2 3 31000 1 1 4 90001 5 20 1 90001 4 10 2 90001 3 3 3 90001 2 2 4 90001 1 1 5 10 rows selected
But I want to see;select plot_number , max(decode(ht_rank, '1', tree_height*100)) ht_1 , max(decode(ht_rank, '2', tree_height*100)) ht_2 , max(decode(ht_rank, '3', tree_height*100)) ht_3 from (select distinct plot_number , tree_number , tree_height , dense_rank() over (partition by plot_number order by tree_height desc)ht_rank from tst_rank order by plot_number, ht_rank asc )txt group by plot_number ; PLOT_NUMBER HT_1 HT_2 HT_3 ----------- ---- ---- ---- 31000 10 3 2 90001 20 10 3
Anyone have some ideas of what I could do to get there?PLOT_NUMBER HT_1 HT_2 HT_3 ----------- ---- ---- ---- 31000 10 10 3 90001 20 10 3
See you soon
Ben
Create script to replicate my problem;
Published by: benton on 9 October 2012 14:45-- drop table tst_rank; CREATE TABLE TST_RANK ( PLOT_NUMBER NUMBER , TREE_NUMBER NUMBER , TREE_HEIGHT NUMBER ); INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('31000','1', '1'); INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('31000','2', '2'); INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('31000','3', '3'); INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('31000','4', '10'); INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('31000','5', '10'); INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('90001','1', '1'); INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('90001','2', '2'); INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('90001','3', '3'); INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('90001','4', '10'); INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('90001','5', '20'); COMMIT; /* select distinct plot_number , tree_number , tree_height , dense_rank() over (partition by plot_number order by tree_height desc)ht_rank from tst_rank order by plot_number, ht_rank asc ; select plot_number , max(decode(ht_rank, '1', tree_height)) ht_1 , max(decode(ht_rank, '2', tree_height)) ht_2 , max(decode(ht_rank, '3', tree_height)) ht_3 from (select distinct plot_number , tree_number , tree_height , dense_rank() over (partition by plot_number order by tree_height desc)ht_rank from tst_rank order by plot_number, ht_rank asc )txt group by plot_number ; */
Use ROW_NUMBER
SQL> select plot_number, 2 max(decode(rn,1,tree_height)) h1, 3 max(decode(rn,2,tree_height)) h2, 4 max(decode(rn,3,tree_height)) h3 5 from( 6 select plot_number,tree_height, 7 row_number() over(partition by plot_number order by tree_height desc) rn 8 from tst_rank) 9 group by plot_number; PLOT_NUMBER H1 H2 H3 ----------- ---------- ---------- ---------- 31000 10 10 3 90001 20 10 3
-
How will I know that an appl system has a shared Top APPL?
Hello
How will I know that an appl system has a shared Top APPL?
View post:
How to find applications are shared or notThank you
A H E E R X -
How can I find the top row of a single table, split among several images in each image.
Hi all.
Thanks in advance.
You can browse all the cells in a row column * and ask the first insertion of a text on his cell point user.user parentTextFrames [0].
If the ID value has changed, the cell is in a different text frame. As well as its line.
CC-2015, it might be a little different, because we have a new type of cell: CellTypeEnum.GRAPHIC_TYPE_CELL (not insertionPoints pave the way).
You can also:
Reproduce all text blocks in history, in that the table is sitting and control for unique tables in duplicates.
Uwe
* edit
-
Hi all
I have the following problem, I have a table with the following data
Parent child
101 201
102 202
201 301
202 302
301 401
301 403
Now I need to write a select query to find the top most parent of the given child, that is to say that I gave my input like 201 302 and 403 so my output should be
Parent child
101 201-> (201 is the son of 101)
102 302-> (302 is the child of 202, 202 is the child of 102)
101 403-> (403 is the child of 301, 301 - > 201, 201-> 101)
Thanks for your help,
REDAHi, Raj,
Welcome to the forum!
Whenever you have any questions, post your examples of data in a form that people can use to recreate the problem and test their solutions.
For example:CREATE TABLE table_x ( parent NUMBER (4) , child NUMBER (4) PRIMARY KEY ); INSERT INTO table_x (parent, child) VALUES (101, 201); INSERT INTO table_x (parent, child) VALUES (102, 202); INSERT INTO table_x (parent, child) VALUES (201, 301); INSERT INTO table_x (parent, child) VALUES (202, 302); INSERT INTO table_x (parent, child) VALUES (301, 401); INSERT INTO table_x (parent, child) VALUES (301, 403); COMMIT;
A WITH clause that, as Whithat posted, is also good.
Always tell what version of Oracle you are using. This is particularly important with parent-child problems, because each version since Oracle 7 has had significant changes in this area. The following query will work in Oracle 10 (and more).
SELECT parent , CONNECT_BY_ROOT child AS child FROM table_x WHERE CONNECT_BY_ISLEAF = 1 START WITH child IN (201, 302, 403) CONNECT BY child = PRIOR parent ;
If you have Oracle 9, then you cannot use CONNECT_BY_ROOT, but you can get the same information from SYS_CONNECT_BY_PATH.
The output of this product, in light of the data from the example above, is:
` PARENT CHILD ---------- ---------- 101 201 102 302 101 403
I guess that's what you wanted, and that the other things you posted your results (such as "---> (201 is the son of 101)"), just explained.
The explanation is very useful, but clearly what you want really to the exit, and what is just your comments.
Maybe you are looking for
-
FireFox Sync is not an option, because the use of an external server is not allowed.Use of third-party modules is not really an option.Import/export is inefficient because it is not put them in the same exact place in every browser. I am happy to be
-
I'm trying to download "Firefox 3.5.10", every attempt by the Government of the results of "the disk image impossible to rise due to the corrupted image. I really need this browser for my e-learning. Help, please! Incidentally 2.0 downloaded fine, bu
-
Original title: usb speaker and seeded c.p. recognize the usb microphone and head studded promp sound but no instructions to continue. I am trying to add voices or narration to my editing of soundtrack.
-
Laptop won't recognize that two of my 5 speakers
Original title: Speaker Setup I have a 5 speaker installed on my HP laptop, but my laptop will only recognize the 2 rear speakers. I changed the speakers that cannot be recognized by the computer with those that are exactly the same model and it stil
-
I had a directory that has been my "contacts". Then moved to z10 & I see that now, my 'Contacts' draw in anyone that I have on twiiter, FB & I don't know where else. OMG there are too many go through this list individually. Why the hell he would add