:::: MENU ::::

Complete the T-SQL query to get the required result

  • Feb 03 / 2012
  • 2
DBA Interview questions, dbDigger, Joins, T-SQL Interview Questions, T-SQL Tips and Tricks

Complete the T-SQL query to get the required result

I came across an interesting question. To get those values of table1 that are not there in table2. This task can be completed very easily by using the EXCEPT operation. However i was required to get the result by appending just a single condition in provided T-SQL code. The trick was about using joins concept to get the required result. Create and populate two tables through following code.

The required result is as shown in the snap

Solve T-SQL puzzle

And just add a single condition either in join clause or in where clause of following query to get the result

And below is the single line condition that is required to get the required result

Complete query would be as following

  • Linda

    Thanks for sharing an interesting question!Interview Questions

  • Linda

    Different jobs require you to dress differently. It is standard practice that, creative’s do not attend interviews in three-piece suits or are lawyers in jeans or flip-flops.

Consult us to explore the Databases. Contact us