# Customized Query throwing ambigious column error

**URL:** <https://community.cdata.com/t/customized-query-throwing-ambigious-column-error/650>\
**Category:** CData Sync\
**Tags:** question\
**Created:** [March 5, 2024, 7:05am UTC](https://community.cdata.com/t/customized-query-throwing-ambigious-column-error/650 "2024-03-05T07:05:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aniruddhmaitra](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@aniruddhmaitra](https://community.cdata.com/u/aniruddhmaitra)\
**Post date:** [March 5, 2024, 7:05am UTC](https://community.cdata.com/t/customized-query-throwing-ambigious-column-error/650/1 "2024-03-05T07:05:38Z")

</div>

Hey! I have written a query in CData Sync to load rows from TransactionAccountingLine _only for a date range, Feb 2024._

```sql
REPLICATE [TransactionAccountingLine]SELECT tranacc.* FROM [TransactionAccountingLine] tranaccLEFT JOIN [transaction] tranON tranacc.transaction = tran.idWHERE tran.trandate between '2024-02-01' and '2024-02-29'

```

Upon running this query, I am getting the error,&nbsp;  
**[0] Column ‘lastmodifieddate’ is ambiguous.**

But I should not be getting this error since&nbsp; I am selecting all the columns only from the TransactionAccountingLine table, where there is only one lastmodifieddate.

Please help me with this issue.

---

<div class="post-metadata">

**Author:** ![DougN\_Nouria](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@DougN\_Nouria](https://community.cdata.com/u/DougN_Nouria)\
**Post date:** [March 5, 2024, 1:59pm UTC](https://community.cdata.com/t/customized-query-throwing-ambigious-column-error/650/2 "2024-03-05T13:59:20Z")

</div>

Sync may be appending WHERE clause on Last Modified Date, in order to do an incremental load.&nbsp; But since that column is in both tables, you get an error.

To get around this -- can you create a database View for your SQL, and use that for the source of your Query?

Or disable incremental loading on this table…

---

<div class="post-metadata">

**Author:** ![aniruddhmaitra](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@aniruddhmaitra](https://community.cdata.com/u/aniruddhmaitra)\
**Post date:** [March 6, 2024, 5:39am UTC](https://community.cdata.com/t/customized-query-throwing-ambigious-column-error/650/3 "2024-03-06T05:39:11Z")

</div>

Could you delve more into how to create a database view?  
Do you mean modifying the customized query I have created?  
I disabled incremental loading like you said and the query is working, but&nbsp;I don’t want to disable incremental loading in the long run.

---

<div class="post-metadata">

**Author:** ![DougN\_Nouria](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@DougN\_Nouria](https://community.cdata.com/u/DougN_Nouria)\
**Post date:** [March 6, 2024, 1:18pm UTC](https://community.cdata.com/t/customized-query-throwing-ambigious-column-error/650/4 "2024-03-06T13:18:55Z")

</div>

Creating a view in the database may or may not be possible for your environment, and a DBA would likely need to help you with that.
