SQL SERVER Puzzles / SQL Puzzles / T-SQL Puzzles


WELCOME TO THE WORLD OF T-SQL PUZZLES / CHALLENGES

List of T SQL Interview puzzles

Here I come with cunning SQL Queries / Puzzles which are frequently asked in SQL / Database / MSBI / SQL BI interviews from developer to Architect level. All the questions below seems easy but it would be complex situation when you face these query in Interview time.

If you have any puzzle in mind or if you want me to solve some puzzle or if you have difficulty in solving business problem please email me @ pawankkmr@gmail.com. I would be happy to help.

This would be best for you to go through following Interview questions / puzzles before attend any technical interview. 

Please visit Interview Puzzles – Finding Outputs section where we have to provide the output based on the query written by the Interviewer.

Sr No SQL Server Puzzle
518 SQL OUTPUT PUZZLE | The Equal to puzzle
517 SQL Puzzle | How to alter a column from null to not null
516 Advanced SQL | Fill the Price for missing months
515 SQL Puzzle | Multiple ways to add Date and Time to a DATETIME | SQL Interview Question
514 SQL Puzzle | The Grouping Puzzle – A Single SELECT | SQL Interview Question
513 SQL Puzzle | The Compare * 100 Puzzle
512 SQL OUTPUT PUZZLE | The JOINs – How well do you know them ? | SQL Interview Question[Updated Answers]
511 SQL OUTPUT PUZZLE | The IN & NOT IN – How well do you know them ? | SQL Interview Question
510 SQL Puzzle | Count total occurrence of a character in all columns | SQL Interview Question
509 SQL Puzzle | Ranking Puzzle – 1 | SQL Interview Question
508 SQL Puzzle | The Hierarchy Spacing Puzzle | SQL Interview Question
507 SQL Server Question | Can we declare a variable/ define a column as INTEGER or DEC?
506 Updated SQL Puzzle | The INNER JOIN – Two Rows PUZZLE | Solution without UNION/UNION All
505 SQL Puzzle | The NOT in Range Puzzle – SINGLE SELECT | SQL Interview Question
504 SQL Puzzle | The INNER JOIN – Two Rows PUZZLE | SQL Interview Question
503 SQL Puzzle | Remove trailing zeros puzzle – The DOUBLE PRECISION/FLOAT(53) data type | Advanced SQLz
502 SQL Puzzle | The SINGLE INSERT Puzzle / The Double INTO Puzzle | Advanced SQL
501 SQL Puzzle | Multiple ways to convert datetime to date with 00:00:00.000 Time | SQL Interview Question
500 SQL Puzzle | Have you ever used SELECT TOP 0 ? – Multiple ways to create a new table from existing | SQL Interview Question
499 SQL Puzzle | The 2 Percentages Puzzle | SQL Interview Question
498 SQL OUTPUT PUZZLE | The BIT Conversion – How well do you know it ? | SQL Interview Question
497 SQL Puzzle | The Distinct Records Multi-Col Puzzle – 1
496 SQL Puzzle | The SUM Puzzle – A SINGLE SELECT
495 SQL Puzzle | Comma Separated String – The SWAP Puzzle | Advanced SQL
494 SQL Puzzle | The Distinct Sequential Unique Records with Count | Advanced SQL
493 SQL Puzzle | The DISTINCT COUNT Without DISTINCT Keyword & With SINGLE SELECT | Advanced SQL
492 SQL Puzzle | The Input Order Puzzle | SQL Interview Question
491 SQL Puzzle | The Latest Product Record – A SINGLE Select | SQL Interview Question
490 SQL OUTPUT PUZZLE | The Case Puzzle | SQL Interview Question
489 SQL Puzzle | The NO Root Puzzle – A SINGLE Select | SQL Interview Question
488 SQL Puzzle | The Next AND The Previous Puzzle | SQL Interview Question
487 SQL Puzzle | The Concatenation Puzzle | SQL Interview Question
486 SQL Puzzle | THE 11th Hour Puzzle | SQL Interview Question
485 SQL Puzzle | THE Multi-Array JSON Read Puzzle | SQL Interview Question
484 SQL Puzzle | Deal with Transpose Record | SQL Interview Question
483 SQL Puzzle | Multiple ways to Split a string and get nth ROW (XML) | Advanced SQL
482 SQL Puzzle | The classic Multi-Column SEARCHING Puzzle | SQL Interview Question
481 SQL Puzzle | The Conditional JOIN Puzzle | SQL Interview Question
480 SQL Puzzle | The Without OR Puzzle | SQL Interview Question
479 SQL Puzzle | The Infamous ROW_NUMBER Puzzle | Advanced SQL
478 SQL Puzzle | The COUNT Puzzle – A SINGLE SELECT ? | SQL Interview Question
477 SQL Puzzle | Convert Multi-Colums to Rows(UNPIVOT Alternative) | Advanced SQL
476 SQL Puzzle | Ignore Records present between Puzzle | Advanced SQL
475 SQL SERVER | How to Create a Date using Day, Month and Year | Multiple Methods
474 SQL OUTPUT PUZZLE | The OUTPUT Puzzle – VIII ? | Advanced SQL
473 SQL PUZZLE | The JOIN Puzzle | Advanced SQL
472 SQL PUZZLE | Insert Hard-coded values along with INSERT-EXEC in a table – Multiple Methods | Advanced SQL
471 SQL OUTPUT PUZZLE | The ADD/ALTER and ALTER Puzzle – ? | Advanced SQL
470 SQL PUZZLE | The Intersection of the Ids Puzzle – Multiple Methods | SQL Interview Question
469 SQL PUZZLE | The IN-NOT IN & UNION Puzzle | SQL Interview Question
468 SQL OUTPUT PUZZLE | The Assignment Puzzle – I | Advanced SQL
467 SQL OUTPUT PUZZLE | The ROUND Puzzle – ? | Advanced SQL
466 SQL PUZZLE | The RANDOM Id PUZZLE | SQL Interview Question
465 SQL OUTPUT PUZZLE | The Assignment Puzzle ? | Advanced SQL
464 SQL PUZZLE | The Last Friday of the Month Puzzle | Advanced SQL
463 SQL PUZZLE | How to convert 13 digit timestamp to Date Time? | Advanced SQL
462 SQL OUTPUT PUZZLE | THE BIT of True and False – How well do you know them ? | SQL Interview Question
461 SQL PUZZLE | The Presence of All Values Puzzle | SQL Interview Question
460 SQL PUZZLE | The Except for Multiple Records? | SQL Interview Question
459 SQL PUZZLE | Can you modify values in Multi-objects JSON array in SQL server? | Advanced SQL
458 SQL PUZZLE | The Distinct and MAX Value Puzzle – A SINGLE SELECT Challenge | SQL Interview Question
457 SQL PUZZLE | How to explicitly Insert the NEXT default value in a Column? | SQL Interview Question
456 SQL PUZZLE | can you use DELETE statement inside a CTE? | SQL Interview Question
454 SQL PUZZLE | Remove NULLs Puzzle | SQL Interview Question
453 SQL PUZZLE | Remove all JSON elements BUT first | Advanced SQL
452 SQL PUZZLE | Round the Vals value to Next whole Number | Advanced SQL
451 SQL PUZZLE | The ONLY type PUZZLE | One of my BEST SQL Interview Question
450 SQL PUZZLE | Can you get Records with at least 6 characters and maximum 10 characters ?
449 SQL PUZZLE | SMALLEST Code to get the NEXT Value? | SQL Interview Question
448
SQL PUZZLE | Count records WHERE Vals LESS 2 between current & previous records | SQL Interview Question
447 SQL PUZZLE | Generate last 5 Quarters with their years | Advanced SQL
446 SQL PUZZLE | The Child XML Node Puzzle | SQL Interview Question
445 SQL PUZZLE | Can you rewrite the LIKE using an IN condition? | SQL Interview Question
444 SQL PUZZLE | THE IDENTITY & CONSTRAINT Puzzle – How well do you know them ? | SQL Interview Question
443 SQL PUZZLE | Fetch ALL Nodes & VALUES dynamically from XML? | Advanced SQL
442 SQL PUZZLE | The Multi Column Creation Puzzle (Multi-JOIN/Conditional Aggregation Puzzle) | SQL Interview Question
441 SQL OUTPUT PUZZLE | THE NULL and UNION – How well do you know them ? | SQL Interview Question
440 SQL PUZZLE | THE Blank RECORDS PUZZLE | Advanced SQL SERVER
439 SQL PUZZLE | Generate a comma separated list via XML | Advance SQL
438 SQL PUZZLE | The Group Status Puzzle | A SINGLE SELECT Interview question
437 SQL PUZZLE | Fetch ALL attributes & values dynamically from XML? | Advanced SQL
436 SQL PUZZLE | The OPTIONAL XML Reading? | Advanced SQL
435 SQL PUZZLE | How to INSERT XML file into SQL Server & fetch data? | SQL Interview Question
434 SQL BASICS | What is the difference between SQL, PL-SQL/PL/pgSQL and T-SQL? | SQL Interview Question?
433 SQL SERVER | How many foreign keys can we have for a table?
432 SQL PUZZLE | The Variable Length Replace Puzzle
431 SQL PUZZLE | Find Maximum value record for each Id? | A SINGLE SELECT Interview Question
430 SQL PUZZLE | Missing Dates for each month ?? | SQL Interview Question
429 SQL PUZZLE | Refill missing data with nearest data using Single SELECT | SQL Interview Question
428 SQL PUZZLE | Multiple ways to add leading zero to single digit month | SQL Interview Question
427 SQL PUZZLE | Summation of MAX Vals – A Single SELECT? | SQL Interview Question
426 SQL PUZZLE | Why Zero is not prefixed with the Month Number? | SQL Interview Question
425 SQL PUZZLE | The children count for #node Puzzle
424 SQL PUZZLE | The NO Infant Puzzle | SQL Interview Question
423 SQL OUTPUT PUZZLE ? | The Concatenation Puzzle | SQL Interview Question
422 SQL PUZZLE | Get data present between two Single QUOTES?? | SQL Interview Question
421 SQL PUZZLE | Get MAX amt Data for each customer using SINGLE SELECT | SQL Interview Question
420 SQL PUZZLE | Multiple ways to Insert multiple rows to a single table having only 1 identity column
419 SQL PUZZLE | Insert NON Matching ROWS in IDENTITY column? | SQL Interview Question
418 SQL PUZZLE | GET Multiple Values or All NULLs ? SQL Interview Question
417 SQL SERVER | Alternate rows color in email using SQL?
416 SQL PUZZLE | Extract data Between Hyphens without using SubString function?
415 SQL PUZZLE | The Parent and Child Puzzle – IV ? | SQL Interview Question
414 SQL Puzzle | How to use Table Variable in Dynamic SQL ? | SQL Interview Question
413 SQL PUZZLE | Can you remove Single/Multiple leading and trailing Commas ? | SQL Interview Question
412 SQL Puzzle | Different ways to remove the last comma from a string | SQL INTERVIEW QUESTION
411 SQL PUZZLE | Retrieve only columns which having at least one not null value | SQL Interview Question
410 SQL Puzzle | READ Multi Level XML DATA using SQL – 1
409 SQL PUZZLE | THE MAX Zero Puzzle | A SINGLE SELECT Interview Question
408 SQL PUZZLE | SUM of Previous 3 rows for each 3 group ROW PER Id Puzzle | SQL Interview Question
407 SQL PUZZLE | SUM EVERY 3 rows for each Id Puzzle | SQL Interview Question
406 SQL PUZZLE | Remove ALL if Others are Present Puzzle | SQL Interview Question
405 SQL PUZZLE | THE Order BY CASE Puzzle | SQL Interview Question
404 SQL PUZZLE | How to Select/Generate numbers between two numbers? | SQL Interview Question
403 SQL PUZZLE | How to calculate GCF of two numbers?
402 SQL PUZZLE | Find string with all same characters? | SQL Interview Question
401 SQL PUZZLE | How to FIX ” Invalid column name ‘Id1’. ” Puzzle | SQL INTERVIEW QUESTION
400 SQL PUZZLE | CATCH ” Msg 207, Level 16, State 1, Line 13 Invalid column name ‘Id1’. ” Puzzle | SQL INTERVIEW QUESTION
399 SQL SERVER | Total and Group By Total Puzzle or The Grouping Sets Puzzle | SQL Interview Question
398 SQL Puzzle | How to import CSV DATA using BULK INSERT?
397 SQL Puzzle | Integers before and after CHR Puzzle | SQL Interview Question
396 (Updated Solutions) to SQL Puzzle | The Tournament Puzzle | SQL INTERVIEW QUESTION
395 SQL Puzzle | Can you Skip Header Row in BULK INSERT?
394 SQL SERVER | Find whether the year is a Leap year or not? | SQL Interview Question
393 (Updated Answers)SQL PUZZLE | The OUTPUT Puzzles : 1 – SQL Interview QUESTION
392 SQL Server | Multiple ways to convert an Integer value to String
391 SQL Puzzle | 5 Ways to GET DISTINCT DATA without using distinct Keyword | SQL Interview Question
390 SQL Puzzle | The Update XML puzzle using SQL
389 SQL Puzzle | Check Node existence in XML using SQL
388 SQL Puzzle | Read XML Data Flat (No Inner Elements) using SQL
387 SQL PUZZLE | The 4 OUTPUT Puzzles – Very Simple SQL Interview QUESTION
386 SQL Puzzle | The ZERO Blank Puzzle | SQL Interview Question (Added 4 tricky solutions)
385 SQL Puzzle | Read and PIVOT XML Data while reading in SQL
384 SQL Puzzle | READ XML DATA(with Attributes-Single/Multi) using SQL – 2
383 SQL Puzzle | Read DATA from XML – 1
382 SQL Puzzle | INSERT multiple rows with single Insert Keyword | SQL Interview Question
381 SQL Puzzle | The TWIN MAX Puzzle | SQL Interview Question
380 SQL Puzzle | Strings containing 3 consecutive numbers in increasing order Puzzle?
379 SQL Puzzle | DISTINCT Count with NULL Puzzle – A SINGLE SELECT? | SQL Interview Question
378 SQL Puzzle | Handling Special characters with For XML PATH(”) Puzzle
377 SQL Puzzle | -Ve +Ve Pair Puzzle | SQL Interview Question
376 SQL Puzzle | The KIND of DATA Puzzle | SQL Interview Question
375 SQL Puzzle | Create 1 Flag for all row but 0 for Last ROW | THE SINGLE SELECT Interview Question
374 SQL Puzzle | Get latest record from XML
373 SQL Puzzle | Repeat the Number Number Times Puzzle
372 SQL Puzzle | The Vertical Minimum for each group Puzzle
371 SQL Puzzle | THE AMAZING NULL PROBLEM | SQL Interview Question
370 SQL Puzzle | DISTINCT + Can you ORDER BY this data? | SQL Interview Question
369 SQL Puzzle | Names with NON repeating characters Puzzle | SQL Interview Question
368 SQL Puzzle | Distinct values from multiple columns Puzzle – SQL Interview Question
367 SQL Puzzle | PIVOT Data + Vertical Sorting Puzzle
366 SQL Puzzle | How to SELECT * except the specified columns in SQL
365 SQL Puzzle | Find Minimum from (col1,col2,col3,col4) with ColumnName | SQL Interview Question
364 SQL Puzzle | Calculate Seconds from Day Hour Minute and Seconds Puzzle | SQL Interview Question
363 SQL Puzzle | Convert JSON Integer array to Table rows | SQL Interview Question
362 SQL Puzzle | Longest Employee Name in each department | Single SELECT | SQL Interview Question
361 SQL Puzzle | Only 2 digits between alphabets puzzle | SQL Server Interview Question
360 SQL Puzzle | The Twin Condition Puzzle | SQL Server Interview Question
359 SQL Puzzle | Employees count in Active Departments Puzzle | Frequent SQL SERVER Interview Question
358 SQL Puzzle | Find SQL but NOT with T SQL keyword Puzzle
357 SQL Puzzle | Sql-puzzle-get-isnull-isnull-next-non-null-value-previous-non-null-value-0-puzzle
356 SQL Puzzle | Find Minimum Value from Multiple Columns Puzzle
355 Rows with at least one integer value or one alphabet – Single SELECT
354 SQL Puzzle | Club Sequence Data(islands) Puzzle
353 SQL Puzzle | Remove Consecutive Integers Puzzle
352 SQL Puzzle | Parse Complex String Data Puzzle
351 SQL Puzzle | Concatenation of columns with comma and add blank if missing data
350 SQL Puzzle | Difference between count & maximum count for each value – The SINGLE Select Puzzle
349 SQL Puzzle | OUTPUT Puzzle – The RIGHT Puzzle
348 SQL Puzzle | Add rows to the data as per the value present in a column
347 SQL Puzzle | Get MIN, MAX, AVG, Last and First Value | The SINGLE SELECT Puzzle
346 SQL Puzzle | The Count Puzzle for Specific Cases
345 SQL Puzzle | The Yes No Pivot Puzzle
344 SQL Puzzle | Club Different Data from two tables Puzzle
343 SQL Puzzle | Number to call Puzzle
342 SQL Puzzle | Inserted and Updated Count Puzzle
341 SQL Puzzle | Get First Character After all occurrences of Underscore from the string
340 SQL Puzzle | How many times the value of a column has changed?
339 SQL Puzzle | Get data based on Index from a column
338 SQL Puzzle | Split String by .(Dot) using XML
337 SQL Puzzle | Find rows with more than 2 dots(.)[Number of occurance of a character in a string]
336 SQL Puzzle | Find Non matching records from Second table
335 SQL Puzzle | Ids with only value “One”
334 SQL Puzzle | Get Integer data from a string column puzzle
333 SQL Puzzle | First row number for every partition should be Even number Puzzle – 11
335 SQL Puzzle | Get data till Integer Value
334 SQL Puzzle | Complete the Data Puzzle
333 SQL Puzzle | UnPivot Data using Cross Apply
332 SQL Puzzle | First row number for every partition should be odd number Puzzle – 1
331 SQL Puzzle | Odd and Even Row Numbers Puzzle
330 SQL Puzzle | Convert data to decimal without using CAST and CONVERT
329 SQL Puzzle | The Permutation Puzzle
328 SQL Puzzle | Fun with SQL-1
327 SQL Puzzle | The ListAggs Puzzle
326 SQL Puzzle | The Tricky NULL Puzzle – 2(CONCAT)
325 SQL Puzzle | The Tricky NULL Puzzle – 1
324 SQL Puzzle | The File Extension Puzzle
323 SQL Puzzle | The Sum of maximum consecutive values puzzle (1)
322 SQL Puzzle | Dynamic Pivot Puzzle
321 SQL Puzzle | Join tables (Only First Row)
320 SQL Puzzle | Generate ranking for groups and within groups
319 SQL Puzzle | The Order By Puzzle – 1
318 SQL Puzzle | Top 2 names in each class without ranking functions
317 SQL Puzzle | Valid Dates > Today’s Date Puzzle
316 SQL Puzzle | Not the Last Order Puzzle
315 SQL Puzzle | Pay amount to workers puzzle
314 SQL Puzzle | Get department count with department data based on a parameter
313 SQL Puzzle | Generate XML Puzzle
312 SQL Puzzle | The Single Select – UNION ALL Data Puzzle
311 SQL Puzzle | Failed thrice in last 3 attempts Puzzle
310 SQL Puzzle | SQL Puzzle | SQL Puzzle | Fetch duplicate data ( The 5 Minutes Puzzle )
309 SQL Puzzle | SQL Puzzle | The Seller Puzzle
308 SQL Puzzle | SQL Puzzle | Strip HTML Characters from a string column in SQL Server
307 SQL Puzzle | The String format Puzzle (INT.INT.INT)
306 SQL Puzzle | Extract Integer Present at the start of the string in a column
305 SQL Puzzle | The Quantity SUM Sales Puzzle
304 SQL Puzzle | The PIVOT Puzzle – VI ( Is Data Present for Id – Y/ Blank )
303 SQL Puzzle | The Header and Detailed Data Puzzle
302 SQL Puzzle | The Count Puzzle
301 SQL Puzzle | The Weird String Puzzle
300 SQL Puzzle | Find Length of longest value from columns in all tables from a database
299 SQL Puzzle | The Complex Hierarchy Puzzle [All Positions below – Line Manager]
298 SQL Puzzle | The BCP OUT with Field Headers Puzzle
297 SQL Puzzle | The Additional Quantity Puzzle
296 SQL Puzzle | Average Time Puzzle
295 SQL Puzzle | The 3 Integers with 2 Dots Puzzle
294 SQL Puzzle | Get Previous and Next Value Puzzle
293 SQL Puzzle | The Next Working Date Puzzle
292 SQL Puzzle | Search Only NVARCHAR Values Puzzle
291 SQL Puzzle | The XML Node Copy Puzzle
290 SQL Puzzle | The Overlapping Dates Puzzle
289 SQL Puzzle | The Non Space Puzzle
288 SQL Puzzle | The XML Explicit Puzzle
287 SQL Puzzle | The 3 Decimal Digits Puzzle
286 SQL Puzzle | The Percentage Puzzle
285 SQL Puzzle | The OrdersAndState puzzle
284 SQL Puzzle | The Merge Puzzle
283 SQL Puzzle | Get DB Name,LogFile Size, MDB File Size and Owner from System Tables
282 SQL Puzzle | The Duplicate diagnosis Puzzle
281 SQL Puzzle | The Date Format (yyyy-MM-dd hh:mm:ss) Puzzle
280 SQL Puzzle | The Address puzzle
279 SQL Puzzle | Phone formatting puzzle
278 SQL Puzzle | Eliminate starting comma(s) and ending comma(s) from a string using Select
277 SQL Puzzle | Time spent by employee in a site
276 SQL Puzzle | The Separation (Chr & Int) Puzzle
275 SQL Puzzle | The Two Underscore Puzzle
274 SQL Puzzle | The Published Post Puzzle
273 SQL Puzzle | The Completed Part Puzzle
272 SQL Puzzle | The Distinct Records Multi-Col Puzzle
271 SQL Puzzle | The Min Max Puzzle
270 SQL Puzzle | The Row Number Puzzle
269 SQL Puzzle | The Phone Number Puzzle
268 SQL Puzzle | The Nbr(Range) Puzzle
267 SQL Puzzle | Find max except negative values
266 SQL Puzzle | Remove Words from a string(column) present in a table
265 SQL Puzzle | Find Grand Parent, Parent and Child Puzzle ( Parent/Child Relationships )
264 SQL Puzzle | The Not Between Puzzle
263
SQL Puzzle | Find Grand Parent, Parent and Child Puzzle ( Parent/Child Relationships )
262 SQL Puzzle | The Ntext Column Problem
261 SQL Puzzle | Append 0 to month if month is < 10(Trick)
260 SQL Puzzle | Get Count of Values from Multiple Columns and Rows
259 SQL Puzzle | Get Count and Numbers Puzzle
258 SQL Puzzle | Find First and Last day of Current Month for Last Year from Current Date
257 SQL Puzzle | The Primary Key Puzzle
256 SQL Puzzle | The nearest date puzzle
255 SQL Puzzle | SELECT Columns which doesn’t have all zero value – II
254 SQL Puzzle | The Varchar column and comma Puzzle
253 SQL Puzzle | The ISNULL Puzzle
252 SQL Puzzle | Create constraint on multiple columns
251 SQL Puzzle | Delete Duplicate Records from a Table but one
250 SQL Puzzle | The Hotel Puzzle
249 SQL Puzzle | The Pivot Puzzle – VII
248 SQL Puzzle | SELECT Columns which doesn’t have all zero value
247 SQL Puzzle | Order By using Parent Child Relationship
246 SQL Puzzle | How to transfer logins and passwords between instances of SQL Server
245 SSAS | Find users who are connected to the SSAS Cube
244 SQL Puzzle | How to Remove Huge Multiple Spaces from a Varchar Field
243 SQL Puzzle | How to move database from one drive to another
242 SQL Puzzle | Order By using Parent Child Relationship
241 SQL Puzzle | Highest and lowest value rows alternatively in SQL Server
240 SQL Puzzle | The Case & Between Puzzle
239 SQL Puzzle | The String Puzzle [Split Puzzle]
238 SQL Puzzle | How to get List of Connections, Username and Database Name on a Server
237 SQL Puzzle | How to get List of Stored Procedures along with the table & column names for all DBs on a SERVER
236 SQL Puzzle | How to get List of Stored Procedures along with the table names in a DB
235 SQL Puzzle | The Updated By Puzzle – I
234 SQL Puzzle | The Updated By Puzzle
233 SQL Puzzle | Get Duplicate Rows from Multiple Columns
232 SQL Puzzle | Script to get growth of the databases size over a given period
231 SQL Puzzle | List of foreign keys with their tables in SQL Server
230 SQL Puzzle | The Late Tolerance Puzzle
229 SQL Puzzle | The Separation Puzzle – 1
228 SQL Puzzle | No of Active Users at each time in the System
227 SQL Puzzle | Update Data that with a string contains apostrophe
226 SQL Puzzle | The XML Path Puzzle
225 SQL Puzzle | First and Second Record – Pivot Format
224 SQL Puzzle | The A & B Puzzle
223 SQL Puzzle | Working Hours Puzzle
222 SQL Puzzle | Remove Duplicate Ints From String Puzzle
221 SQL Puzzle | The Status Puzzle
220 SQL Puzzle | How to Kill all other existing SQL server connection except the login started by current session
219 SQL Puzzle | How to Count total number of Rows in all databases on a Server
218 SQL Puzzle | Remove Duplicate Word(s) from the String/Sentence
217 SQL Puzzle | The Phone Call Puzzle
216 SQL Puzzle | The Greatest Number of Employees (Solution Time:))
215 SQL Puzzle | The Longest Period – II [ SQL Query to Calculate the longest period ( in days ) that the company has gone without hiring or firing any one ] (Solution Time :))
214 SQL Puzzle | The Date Puzzle – II (Solution Time :))
213 SQL Puzzle | 2 Digit Puzzle [No Reverse Function] (Solution Time :))
212 SQL Puzzle | The Date Puzzle – 1
211 SQL Puzzle | Matches won & lost by Each team [Asia Cup Puzzle – II] (Solution Time 🙂 )
210-1 SQL Puzzle | The Asia Cup Puzzle [Solution Time :)]
210 SQL Puzzle | The Event Puzzle
209 SQL Puzzle | The Keys Puzzle
208 SQL Puzzle | The Sum Puzzle – V
207 SQL Puzzle | The Sum Puzzle – VI
206 SQL Puzzle | The Product’s Latest Version Puzzle
205 SQL Puzzle | All values = Val1 Puzzle
204 SQL Puzzle | The Pivot Puzzle – V
203 SQL Puzzle | The Manager & Manager’s Manager Puzzle
202 SQL Puzzle | The Five Consecutive Dates Puzzle
201 SQL Puzzle | The Order By Puzzle
200 SQL Puzzle | Update one table and Insert in another table using single T-SQL statement at same time (Multiple Solutions :))
199 SQL Puzzle | Get File Size using T-SQL
198 SQL Puzzle | The Maximum characters matching in a string Puzzle
197 SQL Puzzle | Remove NULLs via row-wise pattern
196 SQL Puzzle | Sum of Positive, Negative, Total Sum & Sum ignoring -ve values in a single Query
195 SQL Puzzle | Ignore zeros till you get the first non zero value
194 SQL Puzzle | The Ids Puzzle
193 SQL Puzzle | The Header and Footer Puzzle [Difficult Challenge]
192 SQL Puzzle | The Cast Puzzle [Minimum Changes]
191 SQL Puzzle | Getting group by sum with Total Sum in a Single Query [ Multiple Solutions ]
190 SQL Puzzle | Getting sum of current value, previous value and next value in a single query
189 SQL Puzzle | Getting group by sum and total sum in a single query [with Multiple Solutions – Best One]
188 SQL Puzzle | The Replace Puzzle ( Excellent Challenge )
187 SQL Puzzle | Search Phone Number Puzzle (Escape Multiple Characters)
186 SQL Puzzle | Fill the Date Gaps Puzzle (No tally or numbers table)
185 SQL Puzzle | Get # of Hits Per Hour
184 SQL Puzzle | The Missing Gaps Puzzle [Multiple Solutions – Best One]
183 SQL Puzzle | Week on Week sales % Puzzle
182 SQL Puzzle | The Pivot Puzzle [Multiple Solutions – Best One]
181 SQL Puzzle | Delete Duplicate Records using Outer Join
180 SQL Puzzle | Count & Filter Puzzle
179 SQL Puzzle | Word Search Puzzle
178 SQL Puzzle | The Join Puzzle
177 SQL Puzzle | Hiring Years Puzzle
176 SQL Puzzle | No Hiring Years Puzzle
175 SQL Puzzle | How to get Date Part & Time Part only from DateTime in Sql Server [Multiple Methods]
174 SQL Puzzle | Make all UPPER/LOWER case of string to Proper Case/Title Case [Multiple Methods]
173 SQL Puzzle | The Salary Share Puzzle
172 SQL Puzzle | Biggest Prime Number Divisor of an Input Number
171 SQL Puzzle | The String Puzzle – Combine data by one column and then another one using comma
170 SQL Puzzle | Counting occurrences of a substring within a string
169 SQL Puzzle | Generate Numbers – Quickly
168 SQL Puzzle | The Prime Number Puzzle – V
167 SQL Puzzle | The Name Puzzle
166 SQL Puzzle | Generate IDs Puzzle
165 SQL Puzzle | REVERSE a String Without Using Reverse Function / Recursive CTE / While Loop
164 SQL Puzzle | The ASCII Puzzle – II
163 SQL Puzzle | The Consecutive Groups Count Puzzle
162 SQL Puzzle | The Maximum Count of Consecutive Numbers Puzzle
161 SQL Puzzle | Delete Duplicate data from table without using Aggregate & Ranking functions
160 SQL Puzzle | The Separation Puzzle
159 SQL Puzzle | Break Table in Equal Parts
158 SQL Puzzle | Generate Fibonacci Series in SQL Server
157 SQL Puzzle | Fetch 2 records from each salary bracket
156 SQL Puzzle | 5 Prime Numbers above a given number
155 SQL Puzzle | The Maximum Repetition Puzzle
154 SQL Puzzle | Multi Column Pivot Puzzle ( Gmail )
153 SQL Puzzle | Find Strings that contains % Character
152 SQL Puzzle | The Circular Prime Numbers Puzzle
151 SQL Puzzle | Generate Possible combinations of a number puzzle
150 SQL Puzzle | The NULL Columns Puzzle
149 SQL Puzzle | Inserted Rows Count Puzzle
148 SQL Puzzle | Check input parameter value is integer or not – Inbuilt function & Custom Logic
147 SQL Puzzle | Even Odd Count Puzzle
146 SQL Puzzle | Calculate 2nd Highest & 2nd Lowest Salary / Nth Highest and Nth Lowest Salary at the same time
145 SQL Puzzle | The Count different type of characters from a string Puzzle
144 SQL Puzzle | The Multiple Sums Puzzle
143 SQL Puzzle | Get Last 4 Characters from a String without Left & Right Function
142 SQL Puzzle | Generate Random Numbers Within Limits Puzzle
141 SQL Puzzle | The Replace Puzzle
140 SQL Puzzle | The In NotIn Puzzle
139 SQL Puzzle | Multiple Column Pivoting Puzzle
138 SQL Puzzle | Single Query Multiple Condition Puzzle
137 SQL Puzzle | The Fiscal Puzzle – II
136 SQL Puzzle | The Single Update Statement Puzzle
135 SQL Puzzle | Generate Multiple Years Puzzle
134 SQL Puzzle | The Remove NULL Puzzle
133 SQL Puzzle | The Sum of Previous Value to Current Value Puzzle
132 SQL Puzzle | Facebook Puzzle – Count Characters in a string
131 SQL Puzzle | Facebook Puzzle – 1
130 SQL Puzzle | The Yes No Puzzle
129 SQL Puzzle | The Numbers Duplicate Puzzle
128 SQL Puzzle | The SUM Puzzle
127 SQL Puzzle | The Remove duplicate UOM Puzzle
126 SQL Puzzle | Replace Comma Seperated Ids with their Names Puzzle
125 SQL Puzzle | The Fiscal Puzzle
124 SQL Puzzle | The Make Zero Puzzle
123 SQL Puzzle | The User Access Control Puzzle
122 SQL Puzzle | The Max First Rank Puzzle
121 SQL Puzzle | The Comma Separated Puzzle – VI
120 SQL Puzzle | Find Different Values Puzzle
119 SQL Puzzle | Get Weeks (Start Date – End Date) for a Month & Year
118 SQL Puzzle | 2nd Highest Salary in Each Department using OffSet & Fetch Method
117 SQL Puzzle | T-SQL Query Problem
116 SQL Puzzle | The Time Difference Puzzle
115 SQL Puzzle | Check Prime Number Puzzle
114 SQL Puzzle | The Middle 4 Puzzle
113 SQL Puzzle | The Prime Numbers Puzzle
112 SQL Puzzle | Find Square Numbers from Numbers Table Puzzle
111 SQL Puzzle | Split & Count Puzzle
110 SQL Puzzle | The Pattern Puzzle #2 ( Fun with SQL )
109 SQL Puzzle | Simple Pivot – Facebook Puzzle
108 SQL Puzzle | Find every Saturday and their corresponding last months Saturday with in a Year
107 SQL Puzzle | Find every 3rd Tuesday in each month with in a Year
106 SQL Puzzle | Star Pattern Puzzle ( Fun with SQL )
107 SQL Puzzle | Sort Data by Version Puzzle
105 SQL Puzzle | Find Numbers that satisfies | Number – ReverseDIGITS(Number) = SUMOfDIGITS(Number) + MULTIPLICATIONOFDIGITS(Number)
104 SQL Puzzle | Multiplication of Digits Puzzle
103 SQL Puzzle | Sum of Digits Puzzle
102 SQL Puzzle | Convert a string into a table n number of times ( n = length of the string )
101 SQL Puzzle | Convert a string into a table without any delimiter
100 SQL Puzzle | Split String Puzzle – II (Linked In)
99 SQL Puzzle | Second Highest Salary Puzzle – Different Methods & the Best Method
98 SQL Puzzle | Replace 6 or more Consecutive Digits with x from a string Puzzle
97 SQL Puzzle | Records not ending with a character Puzzle – BEST Approach
96 SQL Puzzle | Pivoting Data Puzzle
95 SQL Puzzle | The Remove Nulls Puzzle
94 SQL Puzzle | Minus -1 or Minimum Child Puzzle
93 SQL Puzzle | The Gap Puzzle Puzzle – III
92 SQL Puzzle | The Total Values Missing Puzzle
91 SQL Puzzle | The Gap Puzzle Puzzle – II
90 SQL Puzzle | The FizzBuzz Puzzle
89 SQL Puzzle | Change 0 to 1 and 1 to 0 Puzzle
87 SQL Puzzle | The Tree Puzzle
86 SQL Puzzle | The Previous Value(Non-Null) Puzzle
85 SQL Puzzle | The Median Puzzle
84 SQL Puzzle | The Average Marks Puzzle
83 SQL Puzzle | The Passengers in the Bus Puzzle
82 SQL Puzzle | The Gap Puzzle
81 SQL Puzzle | The Complex Week Puzzle
80 SQL Puzzle | The Grouping Puzzle
79 SQL Puzzle | The Consecutive Wins Puzzle 2
78 SQL Puzzle | The ZIP Grouping Puzzle
77 SQL Puzzle | The Multiple Join Single Query Puzzle
76 SQL Puzzle | The Bitwise Puzzle 
75 SQL Puzzle | The Overlapping Dates Puzzle 
74 SQL Puzzle | The Non Zero Puzzle 
73 SQL Puzzle | The Graph Shortest Path Puzzle 
72 SQL Puzzle | The ASCII Puzzle 
71 SQL Puzzle | The Perfect Number Puzzle 
70 SQL Puzzle | The Complex Time Puzzle 
69 SQL Puzzle | The Multiple Condition Puzzle 
68 SQL Puzzle | The Wild Card Puzzle 
67 SQL Puzzle | The Missing Numbers Puzzle 
66 SQL Puzzle | Distinct A,B,C Puzzle 
65 SQL Puzzle | Multiple Ways to Split a String Puzzle
64 SQL Puzzle | How Many Work/Week Days In Date Range Puzzle
63 SQL Puzzle | The Join and the Aggregate Puzzle
62 SQL Puzzle | AIRPLANES AND PILOTS Puzzle
61 SQL Puzzle | Swap Values of a Column Puzzle
60 SQL Puzzle | Find 2nd highest Salary using Top Clause Puzzle
59 SQL Puzzle | The Student and the Marks Puzzle
58 SQL Puzzle | Count NULL Values Puzzle
57 SQL Puzzle | Count Spaces in a string Puzzle
56 SQL Puzzle | The Training Puzzle 
55 SQL Puzzle | The Missing Gaps Puzzle 
54 SQL Puzzle | The Max Puzzle 
53 SQL Puzzle | The Missing Numbers Puzzle 
52 SQL Puzzle | Complete the Sequence Puzzle 
51 SQL Puzzle | The Send & Ack Puzzle 
50 SQL Puzzle | Matching data between rows and columns Puzzle
49 SQL Puzzle | The Sequencer Puzzle 
48 SQL Puzzle | The Manage and Employee Puzzle – 2
47 SQL Puzzle | The Sorting(Horizontal & Verticle) Puzzle
46 SQL Puzzle | The Version Puzzle
45 SQL Puzzle | The Range Puzzle
44 SQL Puzzle | All Items Puzzle
43 SQL Puzzle | All Products Puzzle
42 SQL Puzzle | Group By – Remove NULL UOM Puzzle
41 SQL Puzzle | The Deal Puzzle
40 SQL Puzzle | The Manager Employee Hierarchy Puzzle
39 SQL Puzzle | The Male and Female Count Puzzle
38 SQL Puzzle | The Friday Salary Puzzle
37 SQL Puzzle | Fruit Count Puzzle
36 SQL Puzzle | Year & Month wise data – The Pivot Puzzle
35 SQL Puzzle | The Case Replace Puzzle
34 SQL Puzzle | The Candidate Joining Problem
33 SQL Puzzle | Find Duplicate Puzzle
32 SQL Puzzle | The Ticket Approver Puzzle
31 SQL Puzzle | The Running Balance Puzzle
30 SQL Puzzle | The Patient Puzzle
29 SQL Puzzle | Multiple Comma Seperated Values Puzzle
28 SQL Puzzle | Remove Duplicate Values Puzzle
27 SQL Puzzle | 2 Decimal Puzzle
26 SQL Puzzle | Fill Missing Values Puzzle
25 SQL Puzzle | Company Code Puzzle
24 SQL Puzzle | The Double Join Puzzle
23 SQL Puzzle | Ignore Duplicate Values Puzzle 
22 SQL Puzzle | Group By XML Path Puzzle
21 SQL | Fishbone Salary puzzle
20 SQL | The Male and Female Puzzle
19 SQL Puzzle | Normalize(Divide) Amount and Months Puzzle 
18 SQL Puzzle | Covert Comma Separated Values to a Table using Cross Apply & XML Puzzle
17 SQL Puzzle | The Candidate Joining Puzzle
16 SQL Puzzle | Consecutive Wins for India Puzzle
15 SQL Puzzle | The Work Order Puzzle
14 SQL | The football Puzzle
13 SQL Puzzle | Gold Rate Puzzle
12 SQL | Group By on Multiple columns Puzzle
11 SQL | Remove ALL Zero Puzzle
10 SQL Puzzle | Department Wise 2nd Highest Salary Puzzle
9 SQL Puzzle | Developer Salary & the Manager Puzzle
8 SQL Puzzle | Finding Maximum Value from multiple columns
7 SQL Puzzle | Sum of Previous Value Puzzle
6 SQL Puzzle | Nth Highest Salary
5 SQL | Remove Unwanted Null Values Puzzle
4 SQL Puzzle | Movie & Role Puzzle
3 SQL Puzzle | BirthDay Puzzle
2 SQL | Finding Next Value Puzzle
1 SQL | Finding Previous Value Puzzle

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.