Академический Документы
Профессиональный Документы
Культура Документы
SELECT MAX(SALARY) FROM EMP WHERE SALARY NOT IN (SELECT MAX(SALARY) FROM EMP);
2)
Max salary from each dept then
SELECT DEPID, MAX(SALARY) FROM EMP GROUPBY DEPID;
7)find number of emp according to gender whose dob id between two given dates,
SELECT COUNT(*), SEX FROM EMP WHERE DOB BETWEEN 'dd/mm/yyyy' AND 'dd/mm/yyyy' G
ROUPBY SEX ;
10) find all emp record where name is like JOE or joe or Joe
SELECT * FROM EMP WHERE UPPER(EMPNAME) LIKE %JOE% ;
11) Write SQL Query to find Duplicate records then delete them in Oracle DB ! Im
portant check it out in internet
********************************************************************************
*******
AnonymousNovember 13, 2013 at 11:25 PM
for selecting the distinct records:
select * from emp a where rowid = (select max(rowid) from emp b where a.empno=b.
empno)
SELECT * FROM EMP a EHERE rowid = ( SELECT MAX(rowid) FROM EMP b where a.empno
= b.empno );
to Delete:
delete from emp a where rowid != (select max(rowid) from emp b where a.empno=b.e
mpno);
DELETE from EMP a WHERE rowid != ( SELECT MAX(rowid) FROM EMP b WHERE a.empno =
b.empno );
-----
I know to ways one way use max and another way use distinct
one way :
DELETE
FROM TestTable
WHERE ID NOT IN
(
SELECT MAX(ID)
FROM TestTable
GROUP BY NameCol)
GO
and
another way
********************************************************************************
*******
12) Find students mark greater then the average !
select student name, marks from table stu where mark > (select avg(mark) from t
able stu) ;
13)
find all emps who are also managers ;
here we may use a self join .. like example
select e.empname, m.empname from emp e, emp m where e.mgrid = m.empid ;
14) you have composite index of three columns and you may provide value of two
columns in where clause of select query
Will index be used for this kind of operaions?
check the internet please !!!!
-----------------
Q1. What is the use of GRANT command?
Ans. GRANT command is used to grant specific user to perform specific task.
Q2. What is the use of SQL check constraint?
Ans. CHECK constraint limits the value range that can be placed in a column.
Difference between rank() and dense_rank() in SQL?
Difference between where and having clause in SQL?
Difference between correlated vs non-correlated subquery?
primary key vs foreign key
truncate vs delete etc.
What is difference between Clustered Index and No-Clustered Index??
SELECT EXTRACT(YEAR FROM DATE '1998-03-07') FROM DUAL;
EXTRACT(YEARFROMDATE'1998-03-07')
---------------------------------
1998