أسئلة القسم

تدرب على أسئلة المقابلات في هذا القسم. اكتب إجابتك، قم بتقييمها، أو اضغط على "عرض الإجابة" بعد التفكير.

Write query for Nth Highest Salary in SQL صعب
SELECT DISTINCT Salary
FROM Employees e1
WHERE N-1 = (
   SELECT COUNT(DISTINCT Salary)
   FROM Employees e2
   WHERE e2.Salary > e1.Salary
);
Extended scenario: If multiple employees have same salary - write using Dense_Rank() صعب
SELECT *
FROM (
   SELECT Name, Salary, DENSE_RANK() OVER (ORDER BY Salary DESC) AS rnk
   FROM Employees
) t
WHERE rnk = N;
Explain the difference between Subquery and Correlated Subquery صعب
  • Subquery: Runs once, result passed to outer query.
  • Correlated Subquery: Runs for each row of outer query.
What is indexed view? صعب

An Indexed View is a view with a unique clustered index.

It materializes results, improving performance on complex queries.

How to implement Partitioning in SQL? صعب

Partitioning splits large tables into smaller, manageable parts.

Types:

  • Range
  • List
  • Hash
  • Composite
What is a Deadlock in SQL? How can you prevent it? صعب

A Deadlock occurs when two transactions wait on each other's locks.

Prevention:

  • Keep transactions short.
  • Access objects in same order.
  • Use proper indexing.
Write steps/queries for SQL Performance tuning صعب

Steps for SQL Performance Tuning:

  • Check execution plans.
  • Add proper indexes.
  • Avoid cursors, prefer set-based operations.
  • Use appropriate JOINs.
  • Optimize queries & schema.
What types of caching are available in .NET? (Related to SQL data) صعب
  • In-Memory Cache: Using IMemoryCache.
  • Distributed Cache: Using IDistributedCache (e.g., Redis, SQL Server).
  • Output Caching: For web responses.
  • EF Core Caching: Query results caching via 3rd-party libraries.