EBSolute Technologies
ALMT Legal Interview Questions and Answers
Q1. Rownumber and partition by in sql or how to find duplicate in table .
ROW_NUMBER() and PARTITION BY are used in SQL to assign a unique row number to each row within a partition.
Use ROW_NUMBER() function along with PARTITION BY clause to assign a unique row number to each row within a partition.
To find duplicates in a table, you can use a combination of ROW_NUMBER() and PARTITION BY to identify rows with row numbers greater than 1.
Example: SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY column_name ORDER BY column_name) AS row_num FROM t...read more
Q2. Joins in sql and what is self join?
Joins in SQL are used to combine rows from two or more tables based on a related column between them. A self join is when a table is joined with itself.
Joins in SQL are used to retrieve data from multiple tables based on a related column.
Types of joins include INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.
A self join is when a table is joined with itself to combine rows based on a related column within the same table.
Q3. How to optimise sql queries?
Optimising SQL queries involves using indexes, avoiding unnecessary joins, and limiting the amount of data retrieved.
Use indexes on columns frequently used in WHERE clauses
Avoid using SELECT * and only retrieve necessary columns
Limit the use of DISTINCT and ORDER BY clauses
Avoid unnecessary joins and use INNER JOIN instead of OUTER JOIN when possible
Use WHERE clause to filter data before joining tables
Q4. Difference between char and varchar.
Char is fixed length data type while varchar is variable length data type in SQL.
Char stores fixed length strings, while varchar stores variable length strings.
Char is padded with spaces to reach fixed length, while varchar does not pad with spaces.
Char is faster for fixed length data, while varchar is more flexible for variable length data.
Q5. What is group by ?
Group by is a clause in SQL used to arrange identical data into groups based on one or more columns.
Group by is used with aggregate functions like COUNT, SUM, AVG, etc.
It is used to summarize data and perform calculations on grouped data.
For example, SELECT department, COUNT(*) FROM employees GROUP BY department;
Q6. Varchar and nvarchar difference.
Varchar stores non-Unicode data while nvarchar stores Unicode data.
Varchar uses 1 byte per character while nvarchar uses 2 bytes per character.
Varchar is faster for storing non-Unicode characters, nvarchar is necessary for multilingual support.
Varchar has a maximum length of 8,000 characters while nvarchar has a maximum length of 4,000 characters.
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month