Query return only last record (transaction) of each customer and product?
Options
![Mauro Mequelussi-1595850](https://us.v-cdn.net/6037124/user_avatars/1595850.jpg)
Mauro Mequelussi-1595850
Member ✭
I have the following scenario:
DATABASE TRANSACTION:
1- CLIENT A - PRODUCT A
2- CLIENT A - PRODUCT A
3- CLIENT B - PRODUCT A
4 - CLIENT C - PRODUCT B
5- CLIENT D - PRODUCT A
6- CLIENT D - PRODUCT A
Every time the customer tries to buy and the purchase is refused, it generates a transaction, but it is for the same product.
How do I return only the last transaction of the same CLIENT and the same PRODUCT. In the case of the above records it should only return:
2- CLIENT A - PRODUCT A
3- CLIENT B - PRODUCT A
4 - CLIENT C - PRODUCT B
6- CLIENT D - PRODUCT A
Can I do this filter in the database?
Comments
-
If I understand you correctly, you can do this with an aggregate and then use addons on top of that.
1. query all records in aggregate mode on the transaction table with a group by client and product.
2. use an aggregator of MAX on the transaction id so you now get client_id, product_id, and max_transaction_id
3. use addons to turn client_id and product_id into their objects
Does that make sense?
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback