So, I'm facing an error while trying to use ORDER BY for 2 columns:
... ORDER BY val, random();
Error is: "2nd ORDER BY term does not match any column in the result set"
I tried different ways to combine ASC sorting for 1st column and random sorting for second column, no luck.
UPDATED to provide more info
CREATE TABLE tabela
(
id
INTEGER,
val
TEXT,
PRIMARY KEY(id
)
);
INSERT INTO tabela (val) VALUES ('paid');
INSERT INTO tabela (val) VALUES ('paid');
INSERT INTO tabela (val) VALUES ('paid');
INSERT INTO tabela (val) VALUES ('standard');
INSERT INTO tabela (val) VALUES ('standard');
INSERT INTO tabela (val) VALUES ('standard');
INSERT INTO tabela (val) VALUES ('standard');
INSERT INTO tabela (val) VALUES ('standard');
Expected sample result:
val id
--- ---
paid 3
paid 1
paid 2
standard 5
standard 8
standard 4
standard 6
standard 7
where 'id' 1,2,3 will be randomly sorted within 'paid' 'val' and 'id' 4 ... 8 will be randomly sorted within 'standard' 'val'