I have the following query:
select *, sum(hrs.WPTOTT) as "Hours"
from mstwmlt
inner join MSTWMPRD hrs
ON hrs.WPOPID = wtopid and hrs.WPTRAN = wtttyp
and (wttdte BETWEEN hrs.WPSDTE AND hrs.WPEDTE)
where (wtwh = ? OR ? = '*ALL')
AND (wtopid = ? OR ? = '*ALL')
AND (wtttyp = ? OR ? = '*ALL')
and ((wtco|| '/' || wtdiv) = ?)
order by wttdte, wtopid, wtttme, wtttyp
I need to select everything and the sum, is there a way to do it without writing a long select query for each individual field?
SUMbeing an aggregate function cannot be applied and selected along with other columns without using aGROUP BYon those columns.