Is it possible to get the difference between 2 rows

I have a table with various scores from multiple 'users' working on the same exams. Each exams has 2 users entering scores for various sections .

What i am trying to calculate is the difference between each score per section for each exam, i noticed there's no built in difference function and i am looking for a work around. The table is data pulled from various tables, that's why its not grouped by exam

Hi @Ted
Sounds like you'll need to do that in SQL with several CTE queries.
There isn't any regular database functions for something like that, since most databases works on columns not rows.

1 Like

Hey @flamber
Thanks for the insight, might you have a link to a resource that could point me in the right direction. In generating the CTE queries

@Ted Here's an explanation about CTE:
https://www.metabase.com/learn/sql-questions/sql-cte
But since I don't know exactly what you are trying to do, then it's difficult to help. Metabase currently doesn't have windowing in GUI questions, which is another way of doing comparison between rows:
https://stackoverflow.com/questions/32068120/how-to-compare-two-rows-in-postgresql

1 Like