All Questions
3 questions
0
votes
1
answer
651
views
Ordering by field, constructed by subquery is slow
My tables (oversimplified for clarity):
documents: registrations:
|id| |id|document_id|date|
My simplified query:
SELECT *
FROM (SELECT documents.*,
(SELECT max(date)
...
0
votes
0
answers
45
views
Postresql using subquery select in order by clause
Is it possible to order by a selected columnname?
SELECT * FROM tablex ORDER BY quote_ident((
select column_name from information_schema.columns
where table_name = tablex AND column_name LIKE '...
11
votes
2
answers
15k
views
How to combine ORDER BY and LIMIT with an aggregate function?
Here is a fiddle for my question.
I have a simple table layout:
class
person: belongs to a class
I want to select all classes, and for each class, I want the first two person identifiers of the ...