Showing posts with label sql querys. Show all posts
Showing posts with label sql querys. Show all posts

Saturday, 10 January 2015


What are joins?Sometimes we have to select data from two or more tables to make our result complete. We have to perform a join.

How many types of Joins?Joins can be categorized as:
Inner joins (the typical join operation, which uses some comparison operator like = or <>). These include equi-joins and natural joins.
Inner joins use a comparison operator to match rows from two tables based on the values in common columns from each table. For example, retrieving all rows where the student identification number is the same in both the students and courses tables.
Outer joins. Outer joins can be a left, a right, or full outer join.
Outer joins are specified with one of the following sets of keywords when they are specified in the FROM clause:

Transact-SQL Optimization Tips

Use views and stored procedures instead of heavy-duty queries.
This can reduce network traffic, because your client will send to server only stored procedure or view name (perhaps with some parameters) instead of large heavy-duty queries text. This can be used to facilitate permission management also, because you can restrict user access to table columns they should not see.

Thursday, 21 November 2013

How do I select 2nd highest salaried employee from my EMPLOYEE table?


How do I select 2nd highest salaried employee from my EMPLOYEE table?
Ans.

SELECT
EMPLOYEE.*, MAX(EMPLOYEE.Salary) AS SalarySecondHighest
FROM EMPLOYEE
WHERE EMPLOYEE.Salary<
(SELECT
MAX(EMPLOYEE.Salary) AS SalaryFirstHighest
FROM EMPLOYEE)

Which date function is used to find the difference between two dates?



Which date function is used to find the difference between two dates?
 
Ans.
SELECT DATEDIFF(dd,'10-10-2010','15-10-2010')

Sunday, 7 July 2013

SQL QUESTIONS

1) What is RDBMS?
2) What are the Properties of the Relational Tables?
3) What is Normalization?
4) What is De-normalization?
5) How is ACID property related to Database?
6) What are the Different Normalization Forms?
7) What is a Stored Procedure?
8) What is a Trigger?
9) What are the Different Types of Triggers?
10) What is a View?
11) What is an Index?
12) What is a Linked Server?
13) What is a Cursor?
14) What is Collation?
15) What is the Difference between a Function and a Stored Procedure?

Popular Posts