Using Sum and ABS statements in MySQL

MySQL / PHP Problem

I need to sum the number of entries in a table where an id > 0 or an  id = 23

Resolution

Use a GROUP BY clause in conjunction with a SUM and an ABS

 

SUM( ABS( id > '0' ) ) GROUP BY ......

Meaning, i want  you to return in each row the total number of entries where the id > some value

 

SUM( ABS( id = '0' ) ) GROUP BY ......

Meaning, i want  you to return in each row the total number of entries where the id = some value

 

 

×

Comments are closed.