3.how Can I Retrive All Records of Emp1 Those Should Not Present in Emp2?
3.how Can I Retrive All Records of Emp1 Those Should Not Present in Emp2?
3.how Can I Retrive All Records of Emp1 Those Should Not Present in Emp2?
1st method-delete from emp a where rowid != (select max(rowid) from emp b
where a.empno=b.empno);
3.How can I retrive all records of emp1 those should not present in emp2?
select count(EMPNO), b.deptno, dname from emp a, dept b where a.deptno=b.deptno group
by b.deptno,dname;
5.Count the total sal deptno wise where more than 2 employees exist.
SELECT deptno, sum(sal) As totalsal
FROM emp
GROUP BY deptno
HAVING COUNT(empno) > 2
8. Display the marks of the student number 1 which are equal to the
marks of the student number 2.
SELECT Note
FROM NOTES
WHERE Num=1 AND Note IN
(SELECT Note FROM NOTES WHERE Num=2);
10. The SQL statement to find the departments that have employees with
a salary higher than the average employee salary
SELECT name FROM dept
WHERE id IN
(
SELECT dept_id FROM emp
WHERE sal >
(SELECT avg(sal)FROM emp)
)
11. Write the SQL to use a sub query which will not return any rows -
when just the table structure is required and not any of the data.
CREATE TABLE new_table AS
SELECT * from table_orig WHERE 1=0;
The sub query returns no data but does return the column names and data types to
the 'create table' statement.
Denormalization means allowing redundancy in a table. The main benefit of denormalization is improved
performance with simplified data retrieval and manipulation. This is done by reduction in the number of joins needed
for data processing.
17. SQL CREATE VIEW Syntax
CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition
11. In a table how can one find all of the employees whose first name
does not start with 'M' or 'A'.
SELECT EmployeeID, FirstName, LastName, HireDate, City FROM Employees
WHERE (FirstName NOT LIKE 'M%') AND (FirstName NOT LIKE 'A%')
SELECT wine
FROM Sells
WHERE price >= ALL(
SELECT price
FROM Sells
);
wines(name, manf)
13.Find the wines that are the unique wine by their manufacturer
SELECT nameFROM wines w1
SELECT bar
FROM Sells
WHERE wine = 'Mike' AND
price =
(SELECT price
FROM Sells
WHERE bar = 'James''s Bar' AND
wine = 'Bille'
);
20. How to find out the 10th highest salary in SQL query?
Table - Tbl_Test_Salary
Column - int_salary
select max(int_salary)
from Tbl_Test_Salary
where int_salary in(select top 10 int_Salary from
Tbl_Test_Salary order by int_salary)
9b. Distinct
SELECT DISTINCT "column_name" FROM "table_name"
9c. Where
SELECT "column_name" FROM "table_name" WHERE "condition"
9d. And/Or
SELECT "column_name" FROM "table_name" WHERE "simple condition" {[AND|OR] "simple condition"}+
9e. In
SELECT "column_name" FROM "table_name" WHERE "column_name" IN ('value1', 'value2', ...)
9f. Between
SELECT "column_name" FROM "table_name" WHERE "column_name" BETWEEN 'value1' AND 'value2'
9g. Like
SELECT "column_name" FROM "table_name" WHERE "column_name" LIKE {PATTERN}
9h. Order By
SELECT "column_name" FROM "table_name" [WHERE "condition"] ORDER BY "column_name" [ASC, DESC]
9i. Count
SELECT COUNT("column_name") FROM "table_name"
9j. Group By
SELECT "column_name1", SUM("column_name2") FROM "table_name" GROUP BY "column_name1"
9k. Having
SELECT "column_name1", SUM("column_name2") FROM "table_name" GROUP BY "column_name1" HAVING
(arithematic function condition)
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: