-
-
Save outoftime/4163589 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE stats ( | |
column_name text, | |
column_value int, | |
test_id uuid, | |
score int, | |
height int, | |
PRIMARY KEY (column_name, column_value, test_id) | |
); | |
-- Now let's say we have a logical row with score=20, height=150 | |
INSERT INTO stats (column_name, column_value, test_id, score, height) VALUES ("score", 20, "some-id", 20, 150); | |
INSERT INTO stats (column_name, column_value, test_id, score, height) VALUES ("height", 150, "some-id", 20, 150); | |
-- And query for score > 20 | |
SELECT test_id, score, height FROM stats WHERE column_name="score" AND column_value > 20 | |
-- This only works if all of your stats are of the same type (or can reasonably be coerced to the same type) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment