Tab (Oxford slang) by Ciro Santilli 35 Updated +Created
University of Cambridge students, CanTabBridgeans.
Phaser hello world by Ciro Santilli 35 Updated +Created
Which two persons are hard to satisfy? by Ciro Santilli 35 Updated +Created
tipitaka.fandom.com/wiki/Puggala-Pannatti-Chap.2:
He who stores up whatever he gets and he who gives away whatever he gets - these two persons are hard to satisfy.
Python __getitem__ by Ciro Santilli 35 Updated +Created
Optical computer by Ciro Santilli 35 Updated +Created
SQL 2D histogram by Ciro Santilli 35 Updated +Created
Let's try it on SQLite 3.40.1, Ubuntu 23.04. Data setup:
sqlite3 tmp.sqlite 'create table t(x integer, y integer)'
sqlite3 tmp.sqlite <<EOF
insert into t values
  (0, 0),
  (1, 1),
  (2, 2),
  (3, 3),
  (4, 4),
  (5, 5),
  (6, 6),
  (7, 7),
  (8, 8),
  (9, 9),
  (10, 10),
  (11, 11),
  (12, 12),
  (13, 13),
  (14, 14),
  (15, 15),
  (16, 16),
  (17, 17),
  (18, 18),
  (19, 19),

  (2, 18)
EOF
sqlite3 tmp.sqlite 'create index txy on t(x, y)'
For a bin size of 5 ignoring empty ranges we can:
sqlite3 tmp.sqlite <<EOF
select
  floor(x/5)*5 as x,
  floor(y/5)*5 as y,
  count(*) as cnt
from t
group by 1, 2
order by 1, 2
EOF
which produces the desired:
0|0|5
0|15|1
5|5|5
10|10|5
15|15|5
And to consider empty ranges we can use SQL genenerate_series + as per stackoverflow.com/questions/72367652/populating-empty-bins-in-a-histogram-generated-using-sql:
sqlite3 tmp.sqlite <<EOF
select x, y, sum(cnt) from (
  select
      floor(x/5)*5 as x,
      floor(y/5)*5 as y,
      count(*) as cnt
    from t
    group by 1, 2
  union
  select *, 0 as cnt from generate_series(0, 15, 5) inner join (select * from generate_series(0, 15, 5))
)
group by x, y
EOF
which outputs the desired:
0|0|5
0|5|0
0|10|0
0|15|1
5|0|0
5|5|5
5|10|0
5|15|0
10|0|0
10|5|0
10|10|5
10|15|0
15|0|0
15|5|0
15|10|0
15|15|5
SQL genenerate_series by Ciro Santilli 35 Updated +Created
PostgreSQL spatial index by Ciro Santilli 35 Updated +Created
SQL FUNCTION keyword by Ciro Santilli 35 Updated +Created
SQL PROCEDURE by Ciro Santilli 35 Updated +Created
Common Table Expression by Ciro Santilli 35 Updated +Created
rm -f tmp.sqlite
sqlite3 tmp.sqlite 'create table t(i integer)'
sqlite3 tmp.sqlite 'insert into t values (1), (2)'
sqlite3 tmp.sqlite 'with mycte as ( select * from t ) delete from mycte where i = 1'
sqlite3 tmp.sqlite 'select * from t'
Nested set model in SQL by Ciro Santilli 35 Updated +Created
How to implement Nested set model in SQL:
SQLite C extension by Ciro Santilli 35 Updated +Created

Unlisted articles are being shown, click here to show only listed articles.