How to eliminate duplicate rows from a table leaving one from the duplicates?
Maxvalue.SQL select the nth highest value from a table
Select level, max('col_name') from my_table where level = '&n' connect by prior ('col_name') >'col_name')group by level;example:given a table called emp with the following columns:-- id number-- name varchar2(20)-- sal number---- for the second highest salary:-- select level, max(sal) from emp--...
Try the below query, it will give the correct output
Select * from emp where salary = (select min(salary) from (select distinct salary from emp order by salary desc) where rownum < n)
-- To get nth Highest from (select salary,dense_rank() over(order by salary desc) as sal from Table )where select distinct salary where sal = &n
select distinct salary
--To get nth Lowest
Find out nth highest salary from emp table
Select distinct (a.Sal) from emp a where &n = (select count (distinct (b.Sal)) from emp b where a.Sal < = b.Sal);for eg:-enter value for n: 2sal---------3700
This will work for only highest salary n=1 but not work for 2nd and rest nth salary...
Did you have tried this?
Code
SELECT * FROM (SELECT employee_id, salary, dense_rank() OVER ( ORDER BY salary DESC) r FROM employees) a WHERE a.r =3 ;
Can a primary key contain more than one columns ?
Yes, a primary key can contain more than one one column. Per EF Cobb's definition, a primary key is the sole candidate key on a relation variable (table) formed from one or more attribute values (c...
in some situations...
if the selected primary key column contains unique row elements..
need only one column....
if it contains any duplicates...then we take two columns
select distinct * from table_name
Delete the Records selected from the below query:
select a.*
from emp1 a, emp1 b
where a.empno = b.empno
and a.rowid < b.rowid
shiv