我想要CASE STHAR_GCKOD when 'G' THEN STHAR_GCMIK >=1
所以我不想要 null 或 0 这可能吗?谢谢..
SELECT
STOK_KODU,
SUM(CASE STHAR_GCKOD WHEN 'G' THEN STHAR_GCMIK ELSE 0 END) // INCOMING,
SUM(CASE STHAR_GCKOD WHEN 'C' THEN STHAR_GCMIK ELSE 0 END) // OUTGOING,
SUM(CASE STHAR_GCKOD WHEN 'G' THEN STHAR_GCMIK ELSE -STHAR_GCMIK END) // TOTAL
FROM
STOKCEK
GROUP BY
STOK_KODU