Op deze mooie lente dag heb ik een vraagje ik kom er namelijk niet meer uit,
SELECT *, t.ticketid as TicketID,
/**********Om deze subquery gaat het**********\
(SELECT SUM((timebillable/60/60)*optionvalue) FROM swtickets t, swtickettimetracks tt, swcustomfieldvalues cfv, swcustomfieldoptions cfo, swuserorganizations, swusers
WHERE t.isresolved = 1
AND swusers.userorganizationid = swuserorganizations.userorganizationid
AND swusers.userid = t.userid
AND tt.ticketid = t.ticketid
AND cfv.typeid = tt.tickettimetrackid
AND cfo.customfieldoptionid = cfv.fieldvalue
GROUP BY swuserorganizations.userorganizationid) as Price,
/***********************************************\
(SELECT SUM((timebillable/60/60)*optionvalue) FROM swtickets t, swtickettimetracks tt, swcustomfieldvalues cfv, swcustomfieldoptions cfo
WHERE t.isresolved = 1
AND tt.ticketid = t.ticketid
AND cfv.typeid = tt.tickettimetrackid
AND cfo.customfieldoptionid = cfv.fieldvalue) as Total,
organizationname,
t.fullname AS Contact,
ticketmaskid AS Ticket,
departmenttitle AS Department,
ticketstatustitle AS TicketStatus
FROM swtickets t, swtickettimetracks tt, swcustomfieldvalues cfv, swcustomfieldoptions cfo, swuserorganizations, swusers
WHERE t.isresolved = 1
AND swusers.userorganizationid = swuserorganizations.userorganizationid
AND swusers.userid = t.userid
GROUP BY swuserorganizations.userorganizationid
ORDER BY t.ticketid
De query die je ziet rekent een aantal dingen uit en vergelijkt ook een aantal dingen,
Wat ik nou heb als probleem is als ik zeg van GROUP BY swuserorganizations.userorganizationid in de subquery dan krijg ik als resultaat dat -> Subquery returns more than 1 row <- en dat klopt want ik krijg 2 resultaten eruit, toch moet ik die resultaten wel hebben, heb ook geprobeerd met INNER JOIN / LEFT JOIN maar daar kreeg ik niet de goeie uitkomst mee.
Heeft iemand de oplossing voor mij? of een goeie aanwijzing?
Alvast bedankt,
Patrick