0% found this document useful (0 votes)
75 views2 pages

SQL Queries for Record Management

The document provides SQL queries for various operations, including finding the second largest salary, retrieving specific records, and deleting duplicate rows. It also includes instructions for creating master and work repositories and managing users in a database. Additionally, it outlines how to list and drop repositories or users from the DBA schema.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views2 pages

SQL Queries for Record Management

The document provides SQL queries for various operations, including finding the second largest salary, retrieving specific records, and deleting duplicate rows. It also includes instructions for creating master and work repositories and managing users in a database. Additionally, it outlines how to list and drop repositories or users from the DBA schema.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

FIRST RECORD FIRST 5 RECORDS 5 - 10 RECORDS 5TH RECORD ------------------------------------------------------1 - HOW TO FIND 2ND LARGEST SALARY RECORD IN THE

TABLE: SELECT * FROM EMPLOYEE WHERE SALARY IN ( SELECT MAX(SALARY) FROM EMPLOYE E WHERE SALARY < (SELECT MAX(SALARY) FROM EMPLOYEE));

2 - HOW TO FIND FIRST RECORD IN THE TABLE; SELECT * FROM customers1 WHERE rownum <=1; 3 - HOW TO FIND FIRST 5 RECORDS IN THE TABLE: SELECT * FROM customers1 WHERE rownum <=5;

4 - HOW TO GET 4TH RECORD FROM EMPLOYEE TABLE: SELECT * FROM (SELECT ROWNUM RN,A.* FROM EMPLOYEE A) B WHERE [Link] = 4; OR SELECT * FROM EMPLOYEE WHERE ROWNUM <=4 MINUS SELECT * FROM EMPLOYEE WHE RE ROWNUM <=3; 5 - HOW TO FIND THE RECORDS FROM 60 TO 70 AMONG 100 RECORDS TABLE: SELECT * FROM ( SELECT ROWNUM RN,A.* FROM EMPLOYEE A) B WHERE [Link] BETWE EN 60 AND 70; 6 - HOW TO DELETE DUPLICATE ROWS IN THE TABLE DELETE FROM EMP WHERE ROWID NOT IN(SELECT MAX(ROWID) FROM EMP GROUP BY I D); 7- How to bring all list in to single column which are related to single catoger ie SELECT LISTAGG(NAME,',') WITHIN GROUP(ORDER BY NAME DESC) NAME,SALARY,CO UNT(*) FROM CUSTOMERS1 GROUP BY SALARY;

CREATING MASTER AND WORK REPOSITORIES:-----------------------------------------------------------CREATE USER ODI_MASTER IDENTIFIED BY MASTER; GRANT CONNECT, RESOURCE TO ODI_MASTER; CREATE USER ODI_WORK IDENTIFIED BY WORK; GRANT CONNECT, RESOURCE TO ODI_WORK;

SELECT USERNAME FROM DBA_USERS;

LIST AND DROPING REPOSITORIES:------------------------------------------------------------TO LIST SCHEMAS IN THE DBA: SELECT * FROM DBA_USERS; SELECT USERNAME FROM DBA_USERS; TO DROP REPOSITORY OR USER FROM DBA:DROP USER <USER NAME> FROM DBA_USERS; DROP USER <USER NAME> FROM DBA_USERS CASCADE;

You might also like