max method
await db.max(
table: 'table',
fields: '*',
group: 'name',
having: 'name',
debug: false,
where:{
'id':['>',1],
}
);
Implementation
Future<double> max({
required String table,
String fields = '',
where = const {},
String group = '',
String having = '',
bool debug = false,
}) async {
if (group != '') group = 'GROUP BY $group';
if (having != '') having = 'HAVING $having';
if (fields == '') throw 'fields cant be empty';
String _where = _whereParse(where);
table = _tableParse(table);
ResultFormat results = await query(
'SELECT max($fields) as _max FROM $table $_where $group $having',
debug: debug);
var n = results.rows.first['_max'];
if (n is int) {
return n.toDouble();
} else {
return n;
}
}