Tag Archives: recursion

SQL Query to find employees with X Consecutive A Grades

One of my friend (Satya) asked a very interesting interview question during the Lunch today. Question is to write a SQL Query to find the employees who received Grade ‘A’ for 3 consecutive years. Self-join is the simple answer to … Continue reading

Posted in Productivity, SQL Query, SQL Server | Tagged , , , , , , | Leave a comment

Example of Recursive Query using CTE – SQL Server

I would like to give a very simple example of recursion using CTE (Common Table Expression) As part of the demo, I will create a table with ID, EmployeeName, and ManagerID indicating org structure. Following CTE queries will fetch the … Continue reading

Posted in Productivity, Script, SQL, SQL Query | Tagged , , , | Leave a comment

SQL – Remove special Characters from string

I had a requirement to eliminate all the special characters except alphabets and numbers. The traditional way to handle it REPLACE( REPLACE( ‘#My &String’, ‘!’, ” ), ‘#’, ” ) was not helping as I need to list all possible … Continue reading

Posted in Script, SQL, SQL Query, Uncategorized | Tagged , , , , , , , , , , , , | Leave a comment