I have some problems with performing a query using Diesel library. I have table:
create table tasks
(
id serial not null
constraint tasks_pkey
primary key,
name varchar(128) not null,
rate numeric(10, 2) default 0 not null,
time_spent numeric(10, 2)
);
Model:
#[derive(Debug, Serialize, Deserialize, Identifiable, Queryable)]
#[table_name="tasks"]
pub struct Task {
pub id: i32,
pub name: String,
pub rate: BigDecimal,
pub time_spent: Option<BigDecimal>
}
Schema:
table! {
tasks (id) {
id -> Int4,
name -> Varchar,
rate -> Numeric,
time_spent -> Nullable<Numeric>,
}
}
The target is that I need to get Sum of rate * time_spent. I meam total amount. Who can help me with that?