For reference, here's the query statement.SELECT DISTINCT call_ticket.ticketid, queue.to_userid, queue.from_userid, queue.deptid, call_ticket.fnum, call_ticket.categoryid, call_ticket.statusid, call_category.call_categorydesc, call_status.statusdesc, DATE_FORMAT(call_notes.call_end,'%m.%d.%y') as fcall_end, queue_importance.queue_imp_desc, queue_importance.queue_imp_id FROM call_ticket, call_notes, queue, queue_importance, call_category, call_status WHERE queue.to_userid = '1' && queue.queue_imp_id = queue_importance.queue_imp_id && call_ticket.ticketid = queue.ticketid && call_notes.ticketid = queue.ticketid && call_ticket.categoryid = call_category.call_categoryid && call_ticket.statusid = call_status.statusid OR queue.from_userid = '1' && queue.queue_imp_id = queue_importance.queue_imp_id && call_ticket.ticketid = queue.ticketid && call_notes.ticketid = queue.ticketid && call_ticket.categoryid = call_category.call_categoryid && call_ticket.statusid = call_status.statusid ORDER BY call_notes.call_end DESC
I'm a little new to SQL and have a problem with an ORDER BY clause in the above query. The query is used to populate a html table wiht information about support calls. The user has an option to sort the columns with header links (ie, by ticket#, date, status, ect). All sort colums rely on the ORDER BY clause. Every sort option works great except for the one listed above. We should only show one ticket for each ticket# listed. What happens here is when I sort by call_notes.call_end there are duplicate ticket numbers in the html table. I checked and found that if there were 14 seperate notes taken for the particular ticket, the ticket would be listed 14 times in my html table. All other ORDER BY options do not have this quirk.As I mentioned I'm new to SQL and am open for suggestions on how to go about correcting this problem, if it can be done at all. I realize I may be leaving out something important, so please ask if you need clarification.