Geld sparen mit PostgreSQL

akretschmer

Datenbank-Guru
Beiträge
10.288
Silvester kommt ja bald, wir sparen uns das Geld für das Feuerwerk:


Code:
WITH  centers AS
  (
  SELECT  angle,
  len,
  ROUND(len * SIN(2 * PI() * angle)) AS x,
  ROUND(len * COS(2 * PI() * angle)) AS y,
  ROUND(len * 0.3)::INTEGER + 1 AS trace
  FROM  (
  SELECT  RANDOM() AS angle,
  8 * (1 - POWER(RANDOM(), 3)) AS len
  FROM  generate_series (1, 50) s
  ) q
  ),
  traces AS
  (
  SELECT  *,
  generate_series(1, trace) AS part
  FROM  centers
  ),
  parts AS
  (
  SELECT  CASE
  WHEN trace = part THEN
  LEAST(len * 0.2, 2)::INTEGER
  ELSE
  TRUNC(angle * 8 - 0.5)::INTEGER % 4 + 3
  END AS symbol,
  TRUNC(x + part * SIN(2 * PI() * angle)) AS x,
  TRUNC(y + part * COS(2 * PI() * angle)) AS y
  FROM  traces
  )
  SELECT  ARRAY_TO_STRING(
  ARRAY(
  SELECT  COALESCE(
  (
  SELECT  SUBSTR(E'.xX\\-/|', MIN(symbol) + 1, 1)
  FROM  parts
  WHERE  x = col - 14
  AND y = row - 12
  ), ' ')
  FROM  generate_series(1, 25) col
  ), ''
  ) AS FIREWORKS
FROM  generate_series(1, 24) row;


Ja, nicht von mir...
 
Werbung:
Werbung:
Zurück
Oben