# Distinct component not taking other attributes ahead

**URL:** <https://matillioncommunity.discourse.group/t/distinct-component-not-taking-other-attributes-ahead/2168>\
**Category:** Matillion ETL\
**Created:** [May 8, 2023, 6:10pm UTC](https://matillioncommunity.discourse.group/t/distinct-component-not-taking-other-attributes-ahead/2168 "2023-05-08T18:10:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aarusajan](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@aarusajan](https://matillioncommunity.discourse.group/u/aarusajan)\
**Post date:** [May 8, 2023, 6:10pm UTC](https://matillioncommunity.discourse.group/t/distinct-component-not-taking-other-attributes-ahead/2168/1 "2023-05-08T18:10:39Z")

</div>

Hi community i am new to matillion

&nbsp;

trying to apply distinct on only some attributes using distinct component but that just drops all other remaining attributes

&nbsp;

please help here

---

<div class="post-metadata">

**Author:** ![ChikaMatillionCommunityMgr](https://avatars.discourse-cdn.com/v4/letter/c/c5a1d2/32.png) [@ChikaMatillionCommunityMgr](https://matillioncommunity.discourse.group/u/ChikaMatillionCommunityMgr)\
**Post date:** [May 8, 2023, 7:13pm UTC](https://matillioncommunity.discourse.group/t/distinct-component-not-taking-other-attributes-ahead/2168/2 "2023-05-08T19:13:03Z")

</div>

Hi [@aarusajan](https://matillioncommunity.discourse.group/u/aarusajan)​ — Welcome to the Matillion Community!

Only these selected columns are passed to the next component. Duplicate records are removed, leaving only distinct values. Completely guessing - what you may need to do is. join on the columns you select to be distinct back to the original data, using those columns as the join key(s).

Hope this helps,

Chika

---

<div class="post-metadata">

**Author:** ![AnudeepK](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@AnudeepK](https://matillioncommunity.discourse.group/u/AnudeepK)\
**Post date:** [May 21, 2023, 11:41am UTC](https://matillioncommunity.discourse.group/t/distinct-component-not-taking-other-attributes-ahead/2168/3 "2023-05-21T11:41:18Z")

</div>

If you are trying to use Matillion , you may use window functions (rank/row number) , partition on your distinct columns and filter the dataset using the window function. That will avoid the need for a self join.

---

<div class="post-metadata">

**Author:** ![aarusajan](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@aarusajan](https://matillioncommunity.discourse.group/u/aarusajan)\
**Post date:** [May 23, 2023, 7:59am UTC](https://matillioncommunity.discourse.group/t/distinct-component-not-taking-other-attributes-ahead/2168/4 "2023-05-23T07:59:46Z")

</div>

Thank You for your help everyone, i will try it today

---

<div class="post-metadata">

**Author:** ![ASD](https://sea2.discourse-cdn.com/flex002/user_avatar/matillioncommunity.discourse.group/asd/32/1323_2.png) [@ASD](https://matillioncommunity.discourse.group/u/ASD)\
**Post date:** [May 9, 2023, 8:11am UTC](https://matillioncommunity.discourse.group/t/distinct-component-not-taking-other-attributes-ahead/2168/5 "2023-05-09T08:11:47Z")

</div>

As [@ChikaMatillionCommunityMgr](https://matillioncommunity.discourse.group/u/ChikaMatillionCommunityMgr)​ mentioned distinct component functions like that.

Adding steps to follow to get all column along with distinct:

1. **In SQL Query (1)**: Add ROW ID to your data using - **_row\_number() OVER( ORDER BY "Columns") as "ID"_**
2. **In SQL Query (2):** On top of SQL Query (1) apply **_group by on columns required as unique and also select min("ID")_**
3. **In Join :** **_SQL Query (1) Inner join SQL Query (1) on ID=min(ID)_**

You should get all columns with distinct/unique applied from join component, make sure to use correct columns in order by for creating ROW ID.

I Hope this helps.
