lhesky / carth

0 stars 0 forks source link

firebird query #2

Open lhesky opened 7 years ago

lhesky commented 7 years ago

im trying to get the right sum amount of performance but even i change the month it return the same amount of sum value here is my code in firebird db.

SELECT distinct e.SURNAME, e.GIVNAME, c.INITIAL as Outlet, SUM(b.AMOUNT) as PERFORMANCE

FROM PAYMST a

left join PAYLEDGER b on b.CTRLNO_INIT = a.CTRLNO_SRC left join BRANCH c on c.CTRLNO = a.BRANCH left join ACTIVITYLOG d on d.CTRLNO = a.CTRLNO_SRC left join SYSUSER e on e.CTRLNO = d.SYSUSER

where right(b.TRNDATE,7)='09.2016' and b.PAYTYPE = 'CASH' or b.PAYTYPE='CHECK' or b.PAYTYPE='CCARD'

group by e.SURNAME, e.GIVNAME, c.INITIAL order by c.INITIAL, e.SURNAME, e.GIVNAME asc

lhesky commented 7 years ago

Please comment on my query to improve