Ska
Ska

Reputation: 6888

SQL: Select rows with bigger than max in another table

Table "TBL1":

a b
1 2
1 3
2 3

Table "TBL2":

a b
1 2
1 3

I tried this:

SELECT a, b
FROM TBL1 Where a > MAX (tbl2.a);

Obviously it didn't work. Ideally the solution would work in sqlite.

Upvotes: 2

Views: 74

Answers (1)

lemon
lemon

Reputation: 15482

You need a subquery for that:

SELECT a, b
FROM TBL1 Where a > (SELECT MAX(a) FROM tbl2);

Check the demo here.

Upvotes: 3

Related Questions