-
-
Highest Average Salary
Construct a query which finds the job with the highest average salary
-
How to retrieve 2nd highest sal in each departement from emp and dept tables using GROUP BY?
EMP table (empno,deptno,sal)
DEPT table(deptno,dname)
i need Deptno, Dname, 2nd_highest_sal_in_dept
in output.
I can easily do this using row_number, Rank,Dense_rank etc but I am unable to do this using Group By.
Please suggest if this can be done using Group By. -
Display Middle Record
How to display middle record in a given table?
-
-
-
-
-
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
-
What is difference between UNIQUE and PRIMARY KEY constraints?
A table can have only one PRIMARY KEY whereas there can be any number of UNIQUE keys. The columns that compose PK are automatically define NOT NULL, whereas a column that compose a UNIQUE is not automatically defined to be mandatory must also specify the column is NOT NULL.
-
Studetnt Result should get Pass (or) Fail
Hi guys try this query
If any student fails in one subject also his result should be Faile r else Pass
condtion is(marks>=40 "PASS" marks -
What is difference between SQL and SQL*PLUS?
SQL*PLUS is a command line tool where as SQL and PL/SQL language interface and reporting tool. Its a command line tool that allows user to type SQL commands to be executed directly against an Oracle database. SQL is a language used to query the relational database(DML,DCL,DDL). SQL*PLUS commands are used to format query result, Set options, Edit SQL commands and PL/SQL.
-
What is difference between a formal and an actual parameter?
The variables declared in the procedure and which are passed, as arguments are called actual, the parameters in the procedure declaration. Actual parameters contain the values that are passed to a procedure and receive results. Formal parameters are the placeholders for the values of actual parameters
-
To get second highest age from the student table
I am trying to get second highest age from the student table.Student table:SQL> desc student; Name Null? Type ----------------------------------------- -------- ----------------- ROLLNO NUMBER NAME VARCHAR2(20) AGE NUMBERAnd...
-
Difference between an implicit & an explicit cursor.
PL/SQL declares a cursor implicitly for all SQL data manipulation statements, including quries that return only one row. However,queries that return more than one row you must declare an explicit cursor or use a cursor FOR loop.Explicit cursor is a cursor in which the cursor name is explicitly assigned to a SELECT statement via the CURSOR...IS statement. An implicit cursor is used for all SQL statements...
-
-
Avoid Data Duplication
If in a table we dont use primary key or any other unique key then how to avoid duplication of data?
-
Select from table without using column name
How can I select column values from a table without knowing the column name ?Suppose , select employee_id from employees , now I don't know the column name and I want to select the column.Please let me know the answer
-
Find manager for employee
ID employee department manager----------------------------------------------1 Suresh c++ NULL 2 Suresh c++ NUll3 Suresh c++ 25 Sarathy testing 26 Rajaraman c# 17 joe Flash 1I have the employee detail table ,In that i want to find the manager for each employee .The employee...
-
How to convert rows in column using SQL in Oracle
How to convert rows in column using SQL in Oracle;
for example
sl_no
1
2
3
4
output is 1234;
How to convert one column value into rows using SQL
for example
employee_name
Kumar
output
K
u
m
a
r
Oracle SQL Interview Questions
Ans