Skip to content

Commit

Permalink
fix: replacing avg for sum in queries
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroLanaspa committed Oct 23, 2024
1 parent 634d3fb commit 9432696
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/proof-of-sql/examples/movies/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,12 @@ fn main() {
&verifier_setup,
);

// Query 3: Calculate the average duration of movies by genre
// Query 3: Calculate the total duration and count of movies by genre
// Note: We're using SUM and COUNT instead of AVG because the current version
// of the SQL parser doesn't support the AVG function. You can calculate the
// average by dividing total_duration by movie_count.
prove_and_verify_query(
"SELECT genre, AVG(duration) AS avg_duration FROM movies GROUP BY genre ORDER BY avg_duration DESC",
"SELECT genre, SUM(duration) AS total_duration, COUNT(*) AS movie_count FROM movies GROUP BY genre ORDER BY total_duration DESC",
&accessor,
&prover_setup,
&verifier_setup,
Expand Down

0 comments on commit 9432696

Please sign in to comment.