From 5c9abec6cb729365439a7f783d63dfc32eeb2955 Mon Sep 17 00:00:00 2001 From: jvech Date: Wed, 3 Jul 2024 21:27:08 -0500 Subject: add: show null agents total as zero done --- src/database.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/database.rs b/src/database.rs index da514ef..e49b5a2 100644 --- a/src/database.rs +++ b/src/database.rs @@ -132,7 +132,7 @@ impl Database { let mut stmt = conn.prepare(" SELECT a.name, sum(r.amount) FROM Registers r - INNER JOIN Agents a + RIGHT JOIN Agents a ON a.id = r.agent_id GROUP BY a.name")?; let mut agents = stmt.query([])?; @@ -141,7 +141,7 @@ impl Database { println!("+{:->20}+{:->11}+", "", ""); while let Some(row) = agents.next()? { let name: String = row.get(0)?; - let amount: i32 = row.get(1)?; + let amount: i32 = row.get(1).unwrap_or(0); println!("|{:>20}| {:>10}|", name, amount); } println!("+{:->20}+{:->11}+", "", ""); -- cgit v1.2.3-70-g09d2