
Scenario 5 : Find the constraint information SELECT Table_Name FROM User_Tables WHERE Table_Name LIKE ‘STU%’ Query2:How to find Selected Tables from a User? Select table_name,Owner from All_tables order by table_name,owner

Make sure that the database user have logged in with SYS user.
#ROWWISE GRANDTOTAL IN ORACLE11G HOW TO#
Query 1: How to Find table name and its owner? There are so many system tables which will find a table specific information. There are times where user needs to find out the table specific information. (select max(rowid) from Employee b where a.Employee_num =b.Employee_num ĭelete from Employee a where rowid != (select max(rowid) from Employee b where a.Employee_num =b.Employee_num Scenario 4 : Find a table specific information Select a.* from Employee a where rowid != When there is a situation where user needs to add unique constraint to column,user needs to delete duplicate rows. These are most used SQL queries in real world to find the duplicate rows and delete it. There are real world situations where user needs to find and delete duplicate rows from the table. Select * from ( select a.*, rownum rnum from ( YOUR_QUERY_GOES_HERE - including the order by ) a where rownum = N_ROWS Scenario 3 : Find and delete duplicate rows Query 3 : Query to find Nth Record from the table. Select * from Employee where Rowid= select max(Rowid) from Employee Query 2: Query to find last record from the table. Query 1 : Query to find First Record from the table. I will divide this scenario in to 3 parts for better understanding of people. There are some situations where user needs to find out the Nth records from the table. Select * from(Select S.*,DENSE_RANK() OVER (PARTITION BY DNO ORDER BY SALARY DESC) DR from Source) S Where S.DR=2 Scenario 2 : Fetching Nth Record from the table. Select min(salary)from(select distinct salary from emp order by salary desc)where rownum<=2 Select distinct Salary from Employee e1 where 2= Select count(distinct Salary) from Employee e2 where e1.salary<=e2.salary User will try multiple queries to find out the same result. There are lot of real time situation where user needs to deal with this kind of situation.


This is most asked Real Time Scenarios in SQL in many industries. Real Time Scenarios in SQL : Scenario 1 : What is Query to find Second highest salary for employee? I have consolidated the different queries from my website so that user will get idea about different Real Time Scenarios in SQL Queries.Everyone have always question in mind that what will be different Real Time Scenarios in SQL Queries? You will find the answer of this query in this article. In my previous articles i have given the proper idea about the complex sql queries and complex sql interview questions.This article gives you idea about different Real Time Scenarios in SQL Queries which contains simple SQL queries as well as complex sql queries.
