Oct 162013
 

Following on from TV shows and albums, we’re onto famous books today. As before, enter your answers in the comments.

select richard
from   musician
where  genre = 'electronica';

select count(*)
from   colours
where  hex_value between '000000' and '313131'
and    red_value = blue_value
and    blue_value = green_value;

select cipher
from   painters
where  style = 'Renaissance'
and    nationality = 'Italian';

  5 Responses to “Quiz Week, Day 3: Book SQL Brainteasers”

  1. 1) Moby-Dick
    2) Shades of grey
    3) Da Vinci Code

    • Very close – how many shades of grey? ;)

      You’ve got the others though, nice work Salek.

      • 51 Shades of grey :)


        WITH basis AS (
        SELECT CHR(CASE WHEN FLOOR((ROWNUM-1)/16) < 10 THEN 48 ELSE 55 END + FLOOR((ROWNUM-1)/16))
        || CHR(CASE WHEN MOD(ROWNUM-1, 16) < 10 THEN 48 ELSE 55 END + MOD(ROWNUM-1, 16)) color
        FROM ( SELECT 1 FROM dual CONNECT BY LEVEL <= 256)
        )
        SELECT b1.color || b3.color || b3.color shades_of_gray
        FROM basis b1
        CROSS JOIN basis b2
        CROSS JOIN basis b3
        WHERE b1.color || b3.color || b3.color BETWEEN '000000' AND '323232'
        AND b1.color = b3.color
        AND b3.color = b2.color

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)