0

[![enter image description here][1]][1] I have two streams customer and customercontact. I am new to azure data factory. I just want to know which activity in data flow transformation will achieve the below sql query result.

(SELECT * FROM customercontact WHERE customerid IN (SELECT customerid FROM customer) ORDER BY timestamp DESC LIMIT 1)

I can utilize Exist transformation for inner query but I am need some help on how I can fetch the first row after sorting customer contact data.So , basically I am looking for a way to add limit/Top/Offset clause in dataflow.

2
  • The query you have will only return the most recent customer's contact.., what you intend to do with the returned contact record (s)? Commented Dec 5, 2021 at 12:42
  • Yes , it will return most recent customer contact. I have join this other table. I need data flow transformation for above mentioned query. Commented Dec 5, 2021 at 13:39

1 Answer 1

0

You can achieve transformation for a given query in data flow with different transformation.

For sorting you can use Sort transformation. Here you can select Order Ascending or descending.

enter image description here

For top few records you can use Rank transformation.

enter image description here

For “IN” clause you can use Exists transformation.

enter image description here

Refer - https://learn.microsoft.com/en-us/azure/data-factory/data-flow-rank

enter image description here

Here is my sample data in SQL as Source

enter image description here

I have used Rank transformation.

enter image description here

After rank transformation one more column i.e. RankColumn got added.

enter image description here

Now to select only top 1 record I have used Filter Row Modifier. I used equals(RankColumn,1) expression to select Top 1 record.

enter image description here

enter image description here

Now finally use Sink activity and run pipeline.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.