LoginSignup
2
2

More than 5 years have passed since last update.

SQLでも愛が生まれたけど

Last updated at Posted at 2016-05-10

コメント欄にシンプルな愛を書きました。

しっくりこない。
16進リテラル文字列と数値の相互変換に手間取った。

元ネタ:愛が生まれた
解説:なんで愛が生まれるのか

with
  t1 (i, v) as ( values
    (1, '生'),
    (2, '死')
  ),
  t2 (i, b) as (
    select
      i,
      substring(convert_to(v,'UTF8')::varchar,2,7)::bit(24)::int
    from
      t1
  ),
  t3 (v) as (
    select
      max(case i when 1 then b end) & max(case i when 2 then b end)
    from
      t2
  )
select
  convert_from(decode(to_hex(v), 'hex'), 'utf8') as result
from
  t3
2
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2