drop table Student_list;
create table Student_list(roll_no number, stu_name varchar2(30));
Insert into Student_list (ROLL_NO,stu_name) values (1,'KING');
Insert into Student_list (ROLL_NO,stu_name) values (2,'BLAKE');
Insert into Student_list (ROLL_NO,stu_name) values (3,'CLARK');
Insert into Student_list (ROLL_NO,stu_name) values (4,'JONES');
Insert into Student_list (ROLL_NO,stu_name) values (5,'SCOTT');
Insert into Student_list (ROLL_NO,stu_name) values (6,'RAGHU');
Insert into Student_list (ROLL_NO,stu_name) values (7,'FORD');
Insert into Student_list (ROLL_NO,stu_name) values (8,'SMITH');
Insert into Student_list (ROLL_NO,stu_name) values (9,'ALLEN');
Insert into Student_list (ROLL_NO,stu_name) values (10,'WARD');
Insert into Student_list (ROLL_NO,stu_name) values (1,'KING');
Insert into Student_list (ROLL_NO,stu_name) values (5,'SCOTT');
Insert into Student_list (ROLL_NO,stu_name) values (7,'FORD');
COMMIT;
select * from Student_list
order by roll_no,stu_name;
SELECT DISTINCT ROLL_NO,STU_NAME
FROM STUDENT_LIST
ORDER BY ROLL_NO,STU_NAME;
SELECT UNIQUE ROLL_NO,STU_NAME
FROM STUDENT_LIST
ORDER BY ROLL_NO,STU_NAME;
SELECT ROLL_NO,STU_NAME
FROM STUDENT_LIST
GROUP BY ROLL_NO,STU_NAME
ORDER BY ROLL_NO,STU_NAME;
SELECT ROLL_NO,STU_NAME
FROM STUDENT_LIST
UNION
SELECT ROLL_NO,STU_NAME
FROM STUDENT_LIST;
SELECT ROLL_NO,STU_NAME
FROM STUDENT_LIST
UNION
SELECT NULL,NULL
FROM DUAL WHERE 1=2;
SELECT ROLL_NO,STU_NAME
FROM STUDENT_LIST
INTERSECT
SELECT ROLL_NO,STU_NAME
FROM STUDENT_LIST;
SELECT ROLL_NO,STU_NAME
FROM STUDENT_LIST
MINUS
SELECT NULL,NULL
FROM DUAL;
SELECT ROLL_NO,STU_NAME FROM (
SELECT ROLL_NO,STU_NAME,
ROW_NUMBER() over(partition by ROLL_NO,STU_NAME
ORDER BY ROLL_NO,STU_NAME) R
FROM STUDENT_LIST)
where R=1;
SELECT ROLL_NO,STU_NAME FROM (
SELECT ROLL_NO,STU_NAME,
RANK() over(partition by ROLL_NO,STU_NAME
ORDER BY ROWNUM) R
FROM STUDENT_LIST)
where R=1;
SELECT * FROM STUDENT_LIST
WHERE ROWID IN (
SELECT MIN(ROWID)
FROM STUDENT_LIST
GROUP BY ROLL_NO,STU_NAME)
ORDER BY ROLL_NO,STU_NAME;
SELECt * FROM STUDENT_LIST A
WHERE 1 = ( SELECT COUNT(1)
FROM STUDENT_LIST B
WHERE A.ROLL_NO = B.ROLL_NO
AND A.STU_NAME = B.STU_NAME
AND A.ROWID >= B.ROWID);
create table Student_list(roll_no number, stu_name varchar2(30));
Insert into Student_list (ROLL_NO,stu_name) values (1,'KING');
Insert into Student_list (ROLL_NO,stu_name) values (2,'BLAKE');
Insert into Student_list (ROLL_NO,stu_name) values (3,'CLARK');
Insert into Student_list (ROLL_NO,stu_name) values (4,'JONES');
Insert into Student_list (ROLL_NO,stu_name) values (5,'SCOTT');
Insert into Student_list (ROLL_NO,stu_name) values (6,'RAGHU');
Insert into Student_list (ROLL_NO,stu_name) values (7,'FORD');
Insert into Student_list (ROLL_NO,stu_name) values (8,'SMITH');
Insert into Student_list (ROLL_NO,stu_name) values (9,'ALLEN');
Insert into Student_list (ROLL_NO,stu_name) values (10,'WARD');
Insert into Student_list (ROLL_NO,stu_name) values (1,'KING');
Insert into Student_list (ROLL_NO,stu_name) values (5,'SCOTT');
Insert into Student_list (ROLL_NO,stu_name) values (7,'FORD');
COMMIT;
select * from Student_list
order by roll_no,stu_name;
SELECT DISTINCT ROLL_NO,STU_NAME
FROM STUDENT_LIST
ORDER BY ROLL_NO,STU_NAME;
SELECT UNIQUE ROLL_NO,STU_NAME
FROM STUDENT_LIST
ORDER BY ROLL_NO,STU_NAME;
SELECT ROLL_NO,STU_NAME
FROM STUDENT_LIST
GROUP BY ROLL_NO,STU_NAME
ORDER BY ROLL_NO,STU_NAME;
SELECT ROLL_NO,STU_NAME
FROM STUDENT_LIST
UNION
SELECT ROLL_NO,STU_NAME
FROM STUDENT_LIST;
SELECT ROLL_NO,STU_NAME
FROM STUDENT_LIST
UNION
SELECT NULL,NULL
FROM DUAL WHERE 1=2;
SELECT ROLL_NO,STU_NAME
FROM STUDENT_LIST
INTERSECT
SELECT ROLL_NO,STU_NAME
FROM STUDENT_LIST;
SELECT ROLL_NO,STU_NAME
FROM STUDENT_LIST
MINUS
SELECT NULL,NULL
FROM DUAL;
SELECT ROLL_NO,STU_NAME FROM (
SELECT ROLL_NO,STU_NAME,
ROW_NUMBER() over(partition by ROLL_NO,STU_NAME
ORDER BY ROLL_NO,STU_NAME) R
FROM STUDENT_LIST)
where R=1;
SELECT ROLL_NO,STU_NAME FROM (
SELECT ROLL_NO,STU_NAME,
RANK() over(partition by ROLL_NO,STU_NAME
ORDER BY ROWNUM) R
FROM STUDENT_LIST)
where R=1;
SELECT * FROM STUDENT_LIST
WHERE ROWID IN (
SELECT MIN(ROWID)
FROM STUDENT_LIST
GROUP BY ROLL_NO,STU_NAME)
ORDER BY ROLL_NO,STU_NAME;
SELECt * FROM STUDENT_LIST A
WHERE 1 = ( SELECT COUNT(1)
FROM STUDENT_LIST B
WHERE A.ROLL_NO = B.ROLL_NO
AND A.STU_NAME = B.STU_NAME
AND A.ROWID >= B.ROWID);