SQL Questions

Q:

Define Trigger

Answer

Trigger allows us to execute a batch of SQL code when an insert, update or delete command is executed against a specific table.


Triggers are special types of stored procedures that are defined to execute automatically in place of or after data modifications. They can be executed automatically on the insert, delete and update operation.

Report Error

View answer Workspace Report Error Discuss

Subject: SQL

0 2330
Q:

How will you find the 3rd max salary in the employment table?

Answer

SELECT DISTINCT(salary) FROM emp as e1 


WHERE (3) = (SELECT COUNT(DISTINCT(salary)) FROM emp as e2  WHERE e1.salary <= e2.salary)

Report Error

View answer Workspace Report Error Discuss

Subject: SQL

1 2329
Q:

What is the difference between UNION and UNION ALL?

Answer

UNION selects only distinct values whereas UNION ALL selects all values and not just distinct ones

Report Error

View answer Workspace Report Error Discuss

Subject: SQL

0 2244
Q:

The multi part identifier could not be bound is

Answer

One of the most common errors that you might face in join statements is 


 


Server: Msg 4104, Level 16, State 1, Line 1
The multi-part identifier could not be bound.


 


A multipart identifier is any description of a field or table that contains multiple parts - for instance MyTable.SomeRow - if it can't be bound that means there's something wrong with it - either you've got a simple typo, or a confusion between table and column. It can also be caused by using reserved words in your table or field names and not surrounding them with [].


 


The main reason for this error is that the source table cannot be found, for example if you have statement such as Table1.OrderDate, and then if you get error above, this means that Table1 cannot be found in the query. Sometimes you can see that source table exists in the query, but T-SQL cannot understand it, especially when you write join statements.

Report Error

View answer Workspace Report Error Discuss

0 2228
Q:

Difference between a query and a statement in SQL?

Answer

An SQL statement is a string of characters that conforms to the syntax and format specified in the international standard.


A query is a statement that returns a record-set.

Report Error

View answer Workspace Report Error Discuss

Subject: SQL

0 2217
Q:

What are the difference between clustered and a non-clustered index?

Answer

- A clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages.


- A non clustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a non clustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.

Report Error

View answer Workspace Report Error Discuss

Subject: SQL

0 2148
Q:

What is Aggregate Functions?

Answer

Aggregate functions perform a calculation on a set of values and return a single value. Aggregate functions ignore NULL values except COUNT function. HAVING clause is used, along with GROUP BY, for filtering query using aggregate values.


Following functions are aggregate functions. 


AVG, MIN CHECKSUM_AGG, SUM, COUNT, STDEV, COUNT_BIG, STDEVP, GROUPING, VAR, MAX. VARP

Report Error

View answer Workspace Report Error Discuss

Subject: SQL

0 2068
Q:

We can modify an existing Company from

A) Company Info > Alter B) Gateway of Tally > Modify Company
C) Company Info > Alter Company D) All of the above
 
Answer & Explanation Answer: A) Company Info > Alter

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: SQL
Job Role: Analyst , Database Administration , IT Trainer

1 2064