How to use subquery statements in Entity::find of SeaORM? #2446
Unanswered
baby195lxl
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to use Rust's SeaORM to implement the following SQL code:
SELECT grade, ARRAY_AGG(DISTINCT student) FROM (SELECT id, grade, student FROM math_class ORDER BY id DESC LIMIT 10000) AS math_class_grade GROUP BY grade.
The code is as follows:However, this code fails to produce the expected result. My PostgreSQL table structure is as follows:
The expected result is to obtain a structure like this:
{ MathGrade {grade: A, students: [tom, jerry]}, MathGrade {grade: B, students: [woody, buzz]}, MathGrade {grade: C, students: [jessie, rex]} }
. However, after running the program, there is no output. The configuration of Cargo.toml is as follows, and the Rust compiler version I am using is rustc 1.82.0 (f6e511eec 2024-10-15). I would appreciate it if someone could help me clear up this confusion, and any reply are welcome. Thanks.Beta Was this translation helpful? Give feedback.
All reactions