Friday, 21 July 2017

SQL Puzzle 2

Q1. How You will replace "A" with "B" and "B" with "A" in the following string "ABAB" ?

  ‘ABAB’ à ‘BABA’

    SELECT REPLACE((REPLACE((REPLACE('ABAB','A','C')),'B','A')),'C','B')

Q2. What would be output of below query ?

    SELECT A.A FROM (SELECT 1 A, 2 B) A
    JOIN
    (SELECT 1 A, 2 B ) B
    ON A.A=B.B

Output:






Q3. What would be output of below query ?

SELECT B.A FROM (SELECT 1 A) A
JOIN
(SELECT 1 A, 2 B) B
ON A.A = B.A


Output:



No comments:

Post a Comment