to find the lowest a salary table
Hello guys,.I need to find the salary low table. What is the easy way to do it.
How do you manage the links?
If you want several rows returned when there are several people with the same salary
SELECT *
FROM(
SELECT a.*,
rank() over (order by salary desc ) rnk
FROM your_table a)
WHERE rnk = 1
If you want to handle differently the links, use a different analytic function. No doubt dense_rank or row_number.
Justin
Tags: Database
Similar Questions
-
Query to find the nth highest salary...
Hi guys,.
I can't understand this query that we got a Web site. It is used to find the nth highest salary of the employee... Can someone explain to me please each and every part of it...
The Charly is:
Select distinct (a.salary)
EMP a
where 1 = (select count (distinct (salary))
b emp
where a.salary < = b.salary)
The "BOLD" part which is the return value... is my main question about this query...
Help, pleaseIt is called a correlated sub query. The inner query is executed for each iteration of the outer query. For example, if the table emp has 14 rows and then for each salary 14 the inner query will run.
The partselect count(distinct(sal)) from emp b where a.sal<=b.sal
actually counts the number of treatments that are less than or equal to the treatment of the outer query.
Clearly for the King, who gets the highest salary is greater than or equal to 1 (himself). It returns the highest salary.SQL> select * 2 from emp a 3 where 1 >= (select count(distinct(sal)) 4 from emp b 5 where a.sal<=b.sal) 6 order by sal desc; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ----------------------------------- --------- ---------- --------- ---------- ---------- ---------- 7839 KING PRESIDENT 17-NOV-81 5000 10
Salary of the first two.
SQL> ed Wrote file afiedt.buf 1 select * 2 from emp a 3 where 2 >= (select count(distinct(sal)) 4 from emp b 5 where a.sal<=b.sal) 6* order by sal desc SQL> / EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ----------------------------------- --------- ---------- --------- ---------- ---------- ---------- 7839 KING PRESIDENT 17-NOV-81 5000 10 7902 FORD ANALYST 7566 03-DEC-81 3000 20 7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
-
Hi guys, I'll try to find the nth highest salary
using the sub query, is there a case in which the following query may fail
Select
* de (
Select
distinct rownum rn,salary from emp_mgr order by rownum) t where t. rn = 3
;
I do something like that, but he got 3 selects, so I'm a worried buit, trying to optimize it
Select * from)
Select rownum rn, t t.salary (salary select distinct from emp_mgr by salary desc)
) rs
where rs.rn = &n;
-
find the closest value in table
Hi all
I need to find the values in the "C" line which is equal or close to the values 'A' in the 2D array, and then I want to show the values of 'B', corresponding to the values of 'C' in table 2D.
How can I fix it?
Thank you!
0.9967 nearest value is 0.993807 in the 8 Cand in row B row, not 1. The differences are 2.893E - 3 and 3.300E - 3.
Subtract each value from the table C. take the absolute value of the difference. To find the index of at least using Max & Min value of B. Using autoindexing array Index, create the output array.
Lynn
-
How can I find the subset of a table that corresponds to a set of conditions/conditions?
I have often encountered this problem in LabVIEW, probably the result of my Matlab based thinking on the tables. Suppose I have a 1 d array that consists of a real number between 0 and 2 (for example):
1.3 0.1 1.9 0.7 1.4 1.5 1.5 0.8 1.3 0.3 1.4 1.4 0.1 0.6 0.1 0.2 1.6 1.6 1.4 0.6 0.1 1.9
and I want to know the average of the subset of values greater than 0.5 and less than 1.2:
average ([0.8 0.7 0.6 0.6]) = 0.6750.
How can I find the subset of the array that satisfies the condition > 0.5 &<1.2>1.2>
For your example (values between 0.5 and 2) If you wish:
I would do something like this:
I have generated just a table of 10 random numbers between 0.0 and 2.0
The following loop sorts the data, using "range and force."
It then displays the data in the selected range.The last step is to take the average
I have attached the VI if you do not want to use the code.
-
How to find the date of a table Max
Hello world
I have two tables in the database. I want to find the maximum routine for a case_id of the lock_date date between jan 20 to January 29, 2012.
But I don't get real output (output routine_date should be 'January 28, 2012' but I m getting "January 31, 2012" ")
Can someone help me where I made the mistake
Master
case_id lock_date
101 23 January 2012
101 January 24, 2012
102 27 January 2012
102 January 29, 2012
101 30 January 2012
101 January 29, 2012
Routine (for current work)
case_id routine_date
101 23 January 2012
103 28 January 2012
102 21 January 2012
102 January 29, 2012
101 21 January 2012
101 28 January 2012
101 31 January 2012
Select m.case_id, r.routine_date from master m, systematic r,
(case_id, max (routine_date) of the systematic group by selecting case_id) rr
where m.case_id = r.case_id
and m.case_id = rr.case_id
and r.routine_date = rr.routine_dateHello
Here are average dradles:
WITH universe AS ( SELECT m.case_id , r.routine_date , MAX (r.routine_date) OVER (PARTITION BY m.case_id) AS max_routine_date FROM master m , routine r WHERE m.case_id = r.case_id AND m.lock_date >= TO_DATE ('20-Jan-2012', 'DD-Mon-YYYY') AND m.lock_date < TO_DATE ('30-Jan-2012', 'DD-Mon-YYYY') ) SELECT case_id , routine_date FROM universe WHERE routine_date = max_routine_date ;
You only want to view rowss whose routine_date is the maximum date in a subset. First get this subset
If the universe of data that you are interested in is just the period from January 20 to January 29, then you can start by getting all the data in this range. This is what the above subquery universe.
Now, you want to see only the rows where routine_date is the max_routine_date within this universe, for each case_id. You can use the analytic MAX function to find out what this max_routine_date.
Published by: Frank Kulash, March 2, 2013 11:59 -
Find the size of a table with partitions; Two questions
DB version: 11.2.0.4
Platform: Oracle Linux 6.4
The slot table MH_PKT_HEADR in UTMSBL schema has more than 5000 partitions.
Because there partitions, you cannot use just view DBA_SEGMENTS to determine the size of the table.
So, I tried to use 2 SQLs mentioned below. Query1 returned 5 GB. But Query2 has returned a value zero. Query2 is actually a note metalink mentioned below, so he cannot deceive you, I guess.
That is the reliable accurate query: Query1 or Query2?
No idea why Query2 returns a Null value?
- Query1
fixed lines 200
Col TABLE_NAME format a18
with
BaseData as)
Select the owner
nom_segment
segment_type
, round (sum (bytes) / 1024/1024/1024) GB
sum (bytes) bytes
count (*) segment_count
of s dba_segments
Group by owner, nom_segment, segment_type
)
,
LOB type as data)
Select the owner
table_name
nom_segment
of dba_lobs
)
,
all_segs like)
Select coalesce (lobs.table_name, basedata.segment_name) table_name
basedata.*
of basedata
left outer join
type LOB data
on (basedata.segment_name = lobs.segment_name
and basedata.owner = lobs.owner)
)
Select table_name
sum (bytes) bytes
sum (gb) GB
of all_segs
where table_name = 'MH_PKT_HEADR'.
and owner = 'UTMSBL. '
Table_name group;
TABLE_NAME BYTES GB
------------------ ---------- ----------
5869469696 5 MH_PKT_HEADR
- Request 2
-Source: how to calculate the size of a Table that contains outline CLOB and BLOB (Doc ID 118531.1()
SELECT
(SELECT SUM (S.BYTES) - the Segment of Table size
FROM DBA_SEGMENTS S
WHERE S.OWNER = UPPER ('UTMSBL') AND
(S.SEGMENT_NAME = UPPER ('MH_PKT_HEADR'))) +
(SELECT SUM (S.BYTES) - the size of the Lob Segment
FROM DBA_SEGMENTS S, DBA_LOBS L
WHERE S.OWNER = UPPER ('UTMSBL') AND
(L.SEGMENT_NAME = S.SEGMENT_NAME AND L.TABLE_NAME = UPPER('MH_PKT_HEADR') AND L.OWNER = UPPER('UTMSBL'))) +
(SELECT SUM (S.BYTES) - the size of the Lob Index
FROM DBA_SEGMENTS S, DBA_INDEXES I
WHERE S.OWNER = UPPER ('UTMSBL') AND
(I.INDEX_NAME = S.SEGMENT_NAME AND I.TABLE_NAME = UPPER('MH_PKT_HEADR') AND INDEX_TYPE = 'LOB' AND I.OWNER = UPPER('UTMSBL')))
"TOTAL TABLE SIZE.
FROM DUAL;
TOTAL TABLE SIZE
----------------
SELECT
(SELECT nvl (SUM (S.BYTES), 0)-dimensions of the Segment Table)
FROM DBA_SEGMENTS S
WHERE S.OWNER = UPPER ('UTMSBL') AND
(S.SEGMENT_NAME = UPPER ('MH_PKT_HEADR'))) +
(SELECT nvl (SUM (S.BYTES), 0)-Segment Lob size)
FROM DBA_SEGMENTS S, DBA_LOBS L
WHERE S.OWNER = UPPER ('UTMSBL') AND
(L.SEGMENT_NAME = S.SEGMENT_NAME AND L.TABLE_NAME = UPPER('MH_PKT_HEADR') AND L.OWNER = UPPER('UTMSBL'))) +
(SELECT nvl (SUM (S.BYTES), 0)-size of the Lob Index)
FROM DBA_SEGMENTS S, DBA_INDEXES I
WHERE S.OWNER = UPPER ('UTMSBL') AND
(I.INDEX_NAME = S.SEGMENT_NAME AND I.TABLE_NAME = UPPER('MH_PKT_HEADR') AND INDEX_TYPE = 'LOB' AND I.OWNER = UPPER('UTMSBL')))
"TOTAL TABLE SIZE.
FROM DUAL;
David Fitzjarrell
-
Find the element of list, table cell, node of the tree, or control by location
One of my favorite on the swing features has the opportunity to get a reference to the component UI via Container.getComponentAt (int x, int y), or a particular list item through JList.locationToIndex (Point p) (or other similar methods). I was not able to find the same or similar functionality in JFX so far... anyone can point me in the right direction?
Thank you!I don't know a way. When I started with JavaFX I had the same issue; However, I found that I actually need to do. Swing I ever need it when I was, say, treatment the mouse clicks on a JList. In JavaFX, you can register handlers with the cells directly. This does not work in the swing (in the least, not without a huge amount of effort). As well as in the swing, how to map a mouse click to a JList to the list item corresponding was to register a listener with the JList and then move the mouse click coordinates to locationToIndex (...), in JavaFX you just save the listener with the cell:
import javafx.application.Application; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.ListCell; import javafx.scene.control.ListView; import javafx.scene.input.MouseEvent; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; import javafx.util.Callback; public class ListTest extends Application { @Override public void start(Stage primaryStage) throws Exception { BorderPane root = new BorderPane(); ListView
listView = new ListView (); listView.getItems().addAll("Apples", "Oranges", "Grapefruit", "Bananas"); listView.setCellFactory(new Callback , ListCell >() { @Override public ListCell call(ListView param) { return new CustomListCell(); } }); root.setCenter(listView); Scene scene = new Scene(root, 300, 300); primaryStage.setScene(scene); primaryStage.show(); } private class CustomListCell extends ListCell { private final EventHandler listener = new EventHandler () { @Override public void handle(MouseEvent event) { System.out.printf("Mouse clicked on list cell with %s (item number %d)",getItem(), getIndex()); if (isEmpty()) { System.out.print(" (Empty cell)"); } System.out.println(); } }; private CustomListCell() { this.addEventHandler(MouseEvent.MOUSE_CLICKED, listener); } @Override public void updateItem(String item , boolean empty) { super.updateItem(item, empty); if (! empty) { setText(item); } else { setText(null); } } } public static void main(String[] args) {launch(args);} } Of course, maybe it's not your use case, and you really need this feature. Someone else can have a more direct response...
-
Kindly help me with the request to find the data in two tables
Hello Guru
Kindly help me to recover the data from two tables-
BASEBALL
LEGAL_ENT_ID (PK)
GAME_ID (FK)
LEGAL_ENT_NM
INACTIVE_DT
DATE OF INS_TS
INS_LOGIN
DATE OF UPD_TS
UPD_LOGIN
FOOTBALL
GAME_ID (PK)
BRKR_NM,
BRKR_ISR_ID
BROKER_SYMBOL
INACTIVE_DT
BRKR_SWIFT_FLG
BRKR_INTERNAL_FLG
BRKR_CATEGORY
UPD_TS
MINORITY_FLG
BROKER_TYP
STATUS
INS_TS
INS_LOGIN
UPD_LOGIN
APP_USER
ACTIVE_FLG
and if I want fecth data from these two tables according to the following condition then it is fine with the suite of applications.
1 select distinct values only table of BASEBALL by using the following query.
SELECT DISTINCT B.GAME_ID as 'CLEARING GAME ID', B.BRKR_NM "NAME of THE GAME of COMPENSATION" OF BASEBALL A, FOOTBALL B WHERE A.BROKER_RELATION_CD IN ('FUTBRKR1', 'FUTBRKR2') AND A.GAME_ID = B.GAME_ID
2 Select all the table BRKR_NM OF FOOTBALL as well by using the query - next
SELECT GAME_ID "RUNNING GAME ID", 'NAME OF THE GAME OF EXECUTION' BRKR_NM SOCCER
Now, my query is that--
I want a query that gives me a combination of above mentioned queries... and if I tried to use Union or Union All, then she is not giving me the result as expected.
I like the result to look like who has a few conditions such as -
1 - the records in the table Football are high vs Baseball table because there is no condition to filter the records of the Football.
2 - football is a superset of records and Baseball is a subset.
3 - COMPENSATION NOM_JEU and RUNNING NOM_JEU may return the same values as well.
I want the result to be in the following form-
EXECUTION ID GAME | NAME OF THE GAME TO RUN. COMPENSATION ID GAME | DELETE THE NAME OF THE GAME.
2123 test1 2345 test5
2456 test10 2456 test10
Thanks in advance. Kindly help me.
Published by: user555994 on January 4, 2011 23:48In the output you want.
All the values of baseball;
Values of football that are matched;
But on what condition you want to match? -
How to find the size of a table with CLOB
Hello
I have a table with CLOB as follows:
SQL > desc INFO_MESSAGES
Name Null? Type
----------------------------------------- -------- ----------------------------
CLNT_OID NOT NULL VARCHAR2 (16)
USR_OID NOT NULL VARCHAR2 (16)
LAST_client_msg_ID VARCHAR2 (36)
LAST_client_msg_DATE DATE
LAST_client_msg CLOB
LAST_USR_MSG_BOD_ID VARCHAR2 (36)
DATE OF LAST_USR_MSG_DATE
CLOB LAST_USR_MSG
Now I just want to find out what is the size/area total absorbed by the table (including the CLOB columns), so how can I find? I think that the usual command does not - the
Select format from dba_segments where nom_segment = "INFO_MESSAGES" is only showing 7 MB, while I think that the table has several GB of space due to the CLOB.
Also to add one more detail: when dba_segments seeking, I see a result like this:
Select * of dba_segments order by bytes DESC;
MIGRTN SYS_LOB0000111131C00008$ $ LOBSEGMENT SAMS DATA1 20690 6 1963 14528000 119013376000 <-the top row
MIGRTN this is the schema where this INFO_MESSAGES table is present.
Thanks,
OrauserN
you will need to add the segment_size of the LOB segments to the segment_size of the table. The connection between the two pieces of information you find in USER_LOBS (or the corresponding ALL_, DBA_ objects).
-
Find the symbol $ in a table
Hello
Anyone having the script or the formula GREP for the below:
I need to find out all the dollar ($) sign in all tables and replace with $rightindenttab.
Search: $#.
Replace: indent $right tab
Kind regards
Vinatier
Try this,
var myTable = app.activeDocument.stories.everyItem().tables.everyItem().getElements(); for(t=0; t
Vandy
-
How to find the data in two tables are the same?
Hi people,
Suppose we have table emp01, have 10 records and create another emp02 as table
create the table emp02 in select * from emp01;
now both the table has the same data.
How to find a 'data' in the two tables are the same?Hello
SELECT * FROM emp01 MINUS SELECT * FROM emp02 UNION SELECT * FROM emp02 MINUS SELECT * FROM emp01
You can also compare resultset hash to select * in emp01 and select * from emp02 by using dbms_sqlhash.
Best regards
Nikolai -
How to find the dependence of a table
Hi all
How to find all packages or procedure which are using specific table. is there a table where we can go and search.
I want to say I called table_A table say and I want to find in what procedure or package will use this table.
Thank you
SreeHello
Query user_source
Concerning
Sarah -
Find the key referenced foreign Table and column
Can someone please refresh my memory?
How can I determine which table and column refers to a foreign key?
For example, with select * from ALL_constraints WHERE TABLE_NAME = 'my_table '; I can see forced CONSTRAINTA_FK and CONSTRAINTB_FK I guess reference another table and column because CONSTRAINT_TYPE = "R", but it isn't that I get. "
I would get all the way to the referenced table and the column I just don't remember how.
Thank you
LouHello
Example:
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0 Connected as hr SQL> SQL> SELECT UC.TABLE_NAME, 2 UC.R_CONSTRAINT_NAME, 3 UCC.TABLE_NAME, 4 UCC.COLUMN_NAME 5 FROM USER_CONSTRAINTS UC, 6 USER_CONS_COLUMNS UCC 7 WHERE UC.R_CONSTRAINT_NAME = UCC.CONSTRAINT_NAME 8 AND uc.constraint_type = 'R' 9 ORDER BY UC.TABLE_NAME, 10 UC.R_CONSTRAINT_NAME, 11 UCC.TABLE_NAME, 12 UCC.COLUMN_NAME; TABLE_NAME R_CONSTRAINT_NAME TABLE_NAME COLUMN_NAME ------------------------------ ------------------------------ ------------------------------ -------------------------------------------------------------------------------- COUNTRIES REG_ID_PK REGIONS REGION_ID DEPARTMENTS EMP_EMP_ID_PK EMPLOYEES EMPLOYEE_ID DEPARTMENTS LOC_ID_PK LOCATIONS LOCATION_ID EMPLOYEES DEPT_ID_PK DEPARTMENTS DEPARTMENT_ID EMPLOYEES EMP_EMP_ID_PK EMPLOYEES EMPLOYEE_ID EMPLOYEES JOB_ID_PK JOBS JOB_ID JOB_HISTORY DEPT_ID_PK DEPARTMENTS DEPARTMENT_ID JOB_HISTORY EMP_EMP_ID_PK EMPLOYEES EMPLOYEE_ID JOB_HISTORY JOB_ID_PK JOBS JOB_ID LOCATIONS COUNTRY_C_ID_PK COUNTRIES COUNTRY_ID TEMP_LEAVE PK_CLIENT CLIENT CLIEND_ID VISITORS SYS_C004169 GROUPS GROUPID VLANGS SYS_C004170 VISITORS VISITORID 13 rows selected SQL>
In the output:
TABLE_NAME R_CONSTRAINT_NAME TABLE_NAME COLUMN_NAME ------------------------------ ------------------------------ ------------------------------ -------------------------------------------------------------------------------- COUNTRIES REG_ID_PK REGIONS REGION_ID
means that a COUNTRY table has a foreing key called REG_ID_PK that points to an array of AREAS. REGION_ID
Kind regardsPublished by: Walter Fernández on March 4, 2009 23:26 - adding explanation...
-
How to find the rank lowest for each student using a Select query?
Hey I'm having a little trouble here
I have this table
Student - Grade
John - 8
Richard - 9
Louis - 9
Francis - 5
John - 13
Richard - 10
Peter - 12
Shades may vary from 0 to 20.
Name - varchar (50)
Grade - wide
I'm trying to generate a SQL search to search for each rank lowest for each student.
So far, I did:
Select s.name, s.grade
s student
where s.grade = (select min (grade) of student)
The result of this search returns me only the rank lowest of all ranks posted above, which is Francis - 5.
I want to find the lowest rank, but not only for Francis, but for all students in the table.
How do I do that?
Thank you in advance.Ok
Now we head into analytical SQL:
with student as (select 'John' name, 8 grade, 'fail' result from dual union all select 'John' name, 13 grade, 'pass' result from dual union all select 'Francis', 5 grade, 'fail' from dual union all select 'Peter', 12, 'pass' from dual) -- End of your test data SELECT name, MAX (result) KEEP (DENSE_RANK FIRST ORDER BY grade) result, MIN (grade) min_grade FROM student GROUP BY name
Please note that I passed ;)
Concerning
PeterTo learn more:
http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/functions056.htm#SQLRF00641
Maybe you are looking for
-
If I'm away from my computer and come back, FF will not update all pages. Just, he sits and turns. The spinner is not green. If I close FF and try to open it again, I get a message already running", then an error message saying that my profile is not
-
Touch screen turns off momentarily...
I have an iPhone 6 Plus. When my screen and fingers are clean, I normally use the touchscreen. But sometimes disables the touch sensor. I can't use the touch to do anything. This happens sometimes when I scroll through things. The phone doesn't freez
-
Toshiba virtual Store account Reset - 24221
Plese reset my account STORE VIRTUAL TOSHIBA 24221
-
How can I remove Apple Watch phone?
How do I disable my Apple Watch with iphone pairing 6
-
Need to report on all database objects changed
Is there a way to create a report that displays all the database objects that have changed in a given period of time? We have FT SQL running, so I can see that they have been collected, I just can't understand how a report out of it. When I create