On 3/30/2018 12:10 PM, Simon Slavin wrote:
On 30 Mar 2018, at 3:48pm, Mark Brand <mabr...@mabrand.nl> wrote:

SELECT MIN((a,b)) = (1, 2) ok  FROM T;
--Error: near line 4: row value misused

SELECT MIN((SELECT a, b)) = (1, 2) ok  FROM T;
--Error: near line 7: row value misused

SELECT (1, 2) = MIN(SELECT a, b FROM T);
--Error: near line 10: near "SELECT": syntax error

You got very close to the right syntax.

SQLite version 3.19.3 2017-06-27 16:48:08
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> CREATE TABLE T (a, b);
sqlite> INSERT INTO T (a, b) VALUES (1, 2), (1, 3), (2, 3);
sqlite> SELECT min(a,b) FROM T;
1
1
2

I don't think that's what the OP had in mind. They didn't want the smaller of a 
and b for each row, but rather the lexicographically smallest (a, b) pair among 
all rows.

Row values support less-than comparison, so it kind of makes sense to expect 
MIN to work on them, too.
--
Igor Tandetnik


_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to