View Full Version : Distinct and DistinctRow


pradaloh
06-19-2007, 07:09 PM
I have a problem using distinct or distinctrow in one of my query. The result shown reflects all records instead of distinct records. May I know what may be the cause of the problem?

Query:
SELECT DISTINCT Assets.*, Depreciation.DepreciationDate, Depreciation.DepreciationAmount
FROM Assets LEFT JOIN Depreciation ON Assets.AssetID=Depreciation.AssetID;

Thanks in advance!

Moniker
06-19-2007, 08:03 PM
You're using the entire Assets table (Assets.*). Assuming that the Assets table has different fields than the depreciation table, that's going to make it unique everytime, regardless of if all the matching fields in the Assets and Depreciation tables match.

To avoid that, you'd have to address each asset field that you want to match up to the depreciation field separately.

pradaloh
06-19-2007, 10:10 PM
Thanks Moniker!

I will try to narrow the fields which I need in my query.

Thanks for your advice.