Google
Information Storage and Retrieval: Decimal to Binary (SQL Puzzle 12)

Pages

Monday, July 21, 2008

Decimal to Binary (SQL Puzzle 12)

Problem: Write an SQL query to convert a given decimal number to its binary equivqlent.
Solution:
select
reverse(max(replace(sys_connect_by_path(sign(bitand(&num,power(2,level-1))),','),','))) from dual
connect by power(2,level-1)<=&num

1 comment:

Anonymous said...

Hmm it looks like your website ate my first comment (it was super long)
so I guess I'll just sum it up what I submitted and say, I'm thoroughly enjoying
your blog. I too am an aspiring blog writer but I'm still new to everything. Do you have any tips for beginner blog writers? I'd
genuinely appreciate it.

Look at my webpage ... Sac A Main Louis Vuitton