17. Here, NULL implies UNKNOWN. It is a simple example to demonstrate the SQL Server derived table. FROM EMPLOYEE, DEPARTMENT. No theoretical questions are included; this article is meant to be helpful in technical coding interviews. Tables as Sets in SQL . empid   empname managerid   deptid  salary  DOB, 1       emp 1       0       1       6000    1982-08-06 00:00:00.000, 2       emp 2       0       5       6000    1982-07-11 00:00:00.000, 3       emp 3       1       1       2000    1983-11-21 00:00:00.000, 13      emp 13      2       5       2000    1984-03-09 00:00:00.000, 11      emp 11      2       1       2000    1989-07-23 00:00:00.000, 9       emp 9       1       5       3000    1990-09-11 00:00:00.000, 8       emp 8       3       1       3500    1990-05-15 00:00:00.000. Display all the information of the EMP table? Answer - Syntax Error. There are multiple options to perform this operation. 33. Consider following 3 tables with one column, How many rows will following query return? Write a query to get employees whos ID is even. What will be the output of following SQL?(tricky). 5. Can you show one row twice in results from a table? 4. Error      c. T2D       d.0, 30. TRUE or FALSE and UNKNOWN. Give data in a table is of format 'NN/NN', verify that the first and last two characters are numbers and that the middle character is '/'. Error      c. 1       d.0, Options -  a.TDAD         b. What is an alternative for TOP clause in SQL? ... As per SQL Server logic, it works on 3 values in matching conditions. A) select * from emp order by sal asc; 4. Copyright © 2003-2020 TechOnTheNet.com. Based on the departments table below, create a SQL table called employees that stores employee number, employee name, department, and salary information. Can you write a query to get employee names ending with a vowel? Do you wonder what the most frequently asked SQL queries are in interviews? N'th highest Salary? Can you write a query to print prime numbers from 1 to 100? Here you will get only one record of "empone". 2. Please write a query to get the maximum salary from each department. (Incorrect syntax near the keyword. What is wrong with the following query? 24. Will following statement give Divide by Zero error? Now, perform query on min of auto pk id, group by duplicate check columns - this will give you. TechOnTheNet.com requires javascript to work properly. Each of the queries in our SQL tutorial is consequential to almost every system that interacts with an SQL database. Use auto increment primary key "add" if not available in the table, as in given example. The following query will not fetch record with the salary of 6000 but also will skip the record with NULL. 11. SQL is incredibly powerful, and like every well-made development tool, it has a few commands which it’s vital for a good developer to know. 13. Can you write a query to get employee names starting and ending with a vowel? Now the only problem with this SQL CREATE TABLE statement is that you have not defined a primary key for the table. Free Demo, Whitepaper, Ignore Embedded BI at Your Own Peril: Why use it in your enterprise apps, Gartner Report, 5 Steps to Build a Business Case for Data and Analytics Governance That Even Humans Will Understand, How To Get Start And End Date Of Week Using Angular 10, Prediction Using Supervised ML ( Prediction Of Marks ), How To Use Behavior Subject In Angular 10, Custom Login And Register With Identity In ASP.NET Core 3.1, How To Create An Application Using ReactJS And Redux. The primary key for the employees table should be the employee number. All rights reserved. There are multiple ways to do this. How can you  DELETE DUPLICATE RECORDS? Now, can you find 3rd, 5th or 6th i.e. What will be the output of the following query? 7. What will be the outputs in the following SQL queries with aggregate functions? This SQL CREATE TABLE example creates a table called suppliers which has 3 columns. 12,        c.Error        d.1, Options -  a.TD         b. 31 What will be the output of given statement? If all values from tbl2 are deleted. 32. 9. How can you find duplicate records in Employee table? Will the following statements  run or give error? Create a foreign key on the employees table that references the departments table based on the department_id field. These queries can be asked you as an Interview Question or they are handy for you in your day to day tasks.. 1.