i have a sql query for summary my table,
$this->where('kriteria =', 'fakir');
$this->where('zona !=', '0');
$this->select('surveyor,zona,kriteria,area');
$this->selectCount('surveyor', 'count');
$this->selectSum('nilai', 'nilai');
$this->groupBy('surveyor');
$this->groupBy('kriteria');
$this->groupBy('area');
$this->orderBy('kriteria', 'ASC');
$this->orderBy('zona', 'ASC');
$this->orderBy('count', 'DESC');
surveyor | zona | kriteria | area | COUNT |
---|---|---|---|---|
RT06 RW07 | 1 | FAKIR | RUNGKUT | 125 |
RT08 RW07 | 1 | FAKIR | RUNGKUT | 78 |
and i need to take only 1 data from the query result but i cant use surveyor cause it contan space. i plan to add maybe like id for identify data that i need but i dont know how, i use codeigniter 4.4.3
I’ve tried call the id but it refer to only one single data from before query
2
Answers
To convert this into a complete SQL query, it would look something like this: