Joe
Joe

Reputation: 42666

How to query multiple rows involving a MAX?

Assume I have a table like this:

column A(int)  column B(int)
       1          2
       2          6
       3          1

I want to write a query like this: SELECT A, B, MAX(B) FROM TABLE and have it return to me:

1, 2, 6
2, 6, 6
3, 1, 6

Most databases do this. SQLite however only returns me one row.

How can I have SQLite apply the MAX method to every row in the resultset?

Upvotes: 0

Views: 115

Answers (1)

Lamak
Lamak

Reputation: 70668

SELECT A, B, (SELECT MAX(B) FROM TABLE) AS MaxB
FROM TABLE

Upvotes: 2

Related Questions