Hacker News new | past | comments | ask | show | jobs | submit login

A good example might be a groupwise maximum. Those always tend to be a bit of a PITA in SQL if you're not writing them regularly. Be interesting to see what it transpiles to, as well.



If you only want maximum of one column, the PRQL is quite simple:

    from my_table
    group column_a (
      aggregate (max column_b)
    )
If you want the row with the maximum value it gets interesting:

    from my_table
    group column_a (
      sort [-column_b]
      take 1
    )
You can read more about group here: https://prql-lang.org/book/transforms/group.html


Opened an issue as I couldn't get this to work against sqlite:

https://github.com/prql/prql/issues/695


Thanks a lot for testing and opening an issue! This is now fixed and released [1]. Let us know if you still face any problems.

(We need better tests against real DBs, which is very much on our roadmap)

[1]: https://github.com/prql/prql/pull/698


Thank you for the amazingly quick fix!




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: