'Select sum for filed with all value is 1 results different with number or rows
This is my query :
SELECT DISTINCT murid.ID,
CASE WHEN ..... AS Jumlah
FROM murid
JOIN ...
JOIN ...
WHERE ....
It results 15 rows with 'Jumlah' has all value is '1'.
When I add sum for Jumlah like this...
SELECT DISTINCT murid.ID,...
SUM(CASE WHEN ..... ) AS Jumlah
FROM murid
JOIN ...
JOIN ...
WHERE ....
It results Jumlah with value 28. I only add sum but it result different value.
This value of '28' seems number of rows when I remove DISTINCT.
Somebody please help me, thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
