Synechron
10+ Hamdard Interview Questions and Answers
Q1. provide o/p for innerjoin, left join, right join, cross join on a(1,1,1,2,2,3) b(1,1,2,4)
Different types of SQL joins with given data sets a and b.
Inner join: Returns rows where there is a match in both tables (1,1)
Left join: Returns all rows from the left table and the matched rows from the right table (1,1,1,2,2)
Right join: Returns all rows from the right table and the matched rows from the left table (1,1,2,4)
Cross join: Returns the Cartesian product of the two tables (1,1,1,1,1,2,1,4,1,1,2,1,2,2,1,4,2,1,2,2,2,2,4,3,1,1,3,1,2,3,1,4,3,1,1,3,2,2,3,2,4,3,1,2,3,2,...read more
Q2. what are Index and types of index
Indexes are data structures that improve the speed of data retrieval operations in a database.
Indexes are used to quickly locate data without having to search every row in a database table.
Types of indexes include clustered, non-clustered, unique, and composite indexes.
Clustered indexes determine the physical order of data in a table, while non-clustered indexes store a separate copy of the indexed columns.
Unique indexes ensure that no two rows have the same values in the ind...read more
Q3. difference between groupby and having clause
GROUP BY is used to group rows that have the same values into summary rows, while HAVING is used to filter groups based on a specified condition.
GROUP BY is used with aggregate functions to group the result set by one or more columns.
HAVING is used to filter groups based on a specified condition after the GROUP BY clause.
GROUP BY is used before the HAVING clause in a query.
Example: SELECT department, COUNT(*) FROM employees GROUP BY department HAVING COUNT(*) > 5;
Q4. difference between Primary key and Unique key
Primary key uniquely identifies each record in a table, while Unique key allows only one instance of a value in a column.
Primary key does not allow NULL values, while Unique key allows one NULL value.
Primary key automatically creates a clustered index, while Unique key creates a non-clustered index by default.
Primary key can be referenced by foreign keys, while Unique key cannot be referenced by foreign keys.
Q5. diffrenc between function and store procedure
Functions return a value, while stored procedures do not. Functions can be used in SELECT statements, stored procedures cannot.
Functions return a single value, while stored procedures can return multiple values or none at all.
Functions can be used in SELECT statements to return a value, while stored procedures cannot be used in this way.
Functions can be called from within stored procedures, but stored procedures cannot be called from within functions.
Q6. row_number, rank, dense_rank with example
row_number, rank, dense_rank are window functions in SQL used to assign a unique number to each row based on specified criteria.
row_number() assigns a unique sequential integer starting from 1 to each row in the result set
rank() assigns a unique rank to each row based on the specified ordering criteria, with gaps in ranking for ties
dense_rank() assigns a unique rank to each row based on the specified ordering criteria, with no gaps in ranking for ties
Q7. write a sql query depart wise max salary
SQL query to retrieve the maximum salary for each department
Use the MAX() function to find the maximum salary
Group the results by department using the GROUP BY clause
Join the employee table with the department table to get the department information
Q8. what are Types of joins
Types of joins in SQL are Inner Join, Left Join, Right Join, and Full Join.
Inner Join: Returns rows when there is a match in both tables.
Left Join: Returns all rows from the left table and the matched rows from the right table.
Right Join: Returns all rows from the right table and the matched rows from the left table.
Full Join: Returns rows when there is a match in one of the tables.
Q9. what are DML commands
DML commands are Data Manipulation Language commands used to manage data in a database.
DML commands include INSERT, UPDATE, DELETE, and SELECT.
INSERT is used to add new rows of data into a table.
UPDATE is used to modify existing data in a table.
DELETE is used to remove rows of data from a table.
SELECT is used to retrieve data from a database.
Q10. what is execution plan
Execution plan is a roadmap that SQL Server uses to execute a query, showing the steps taken to retrieve data.
Execution plan is generated by the query optimizer to determine the most efficient way to execute a query.
It shows the order in which tables are accessed, joins are performed, and filters are applied.
Execution plan can be viewed using tools like SQL Server Management Studio or by using the EXPLAIN statement in some databases.
Q11. what is trigger
A trigger is a special type of stored procedure that automatically executes when certain events occur in a database.
Triggers can be used to enforce business rules, maintain referential integrity, and automate repetitive tasks.
Examples of trigger events include INSERT, UPDATE, and DELETE operations on a table.
Triggers can be defined to execute before or after the triggering event.
More about working at Synechron
Reviews
Interviews
Salaries
Users/Month