Duplicates in SQL Results
This probably belongs better in a SQL forum...Or mabe somewhere else on THIS forum...But I'm in a bind and don't know what else to do.
Here's my query:
<cfquery name="getCompanyOrders" datasource="#application.DSN#"> SELECT O.*, OL.*, P.* FROM tbl_Order O INNER JOIN tbl_OrderLine OL ON OL.fk_orderID = O.pk_orderID INNER JOIN tblProduct P ON P.pk_productID = OL.fk_productID WHERE P.fk_supplierID = #attributes.companyID# AND O.orderDate BETWEEN '#datebeg#' AND '#dateend#' </cfquery>
This gives me everything I want, but I want it to order these results by a unique identifier in tbl_Order, pk_orderID. This result gives duplicate pk_orderID's, and I was wondering how I can select distinct ones only. When I use "select distinct", it removes all the other information I need from the other joined tables.
Any ideas?
Thank you!
