Skip to content

Instantly share code, notes, and snippets.

@LitKnd
Created June 23, 2017 17:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save LitKnd/d19072dce6d3a5f494d56f561c8869e6 to your computer and use it in GitHub Desktop.
/*****************************************************************************
Copyright (c) 2017 SQL Workbooks LLC
Terms of Use: https://sqlworkbooks.com/terms-of-service/
Contact: help@sqlworkbooks.com
This is only suitable for test environments.
******************************************************************************/
/* Question 1 */
SELECT 1 WHERE 1=0;
/* Question 2 */
SELECT 1 A ;
/* Question 3 */
SELECT *
FROM (VALUES (1), (2), (3)) AS val(num);
/* Question 4 */
SELECT *
FROM (VALUES (1), (2), (3)) AS val(num)
WHERE EXISTS
(SELECT 1/0);
/* Question 5 */
SELECT
val.num + 100 as new_total
FROM (VALUES (1), (2), (3)) AS val(num)
WHERE new_total = 101;
/* Question 6 */
SELECT
new_total.num
FROM (VALUES (1), (2), (3)) AS val(num)
CROSS APPLY (SELECT val.num + 100) as new_total(num)
WHERE new_total.num = 101;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment