How to get current data according to the time when it is updated

I am uploading a CSV file which is been uploaded row wise in my couchbase. Now I want to show that data in table form in UI but while querying I’m getting old data first then the latest data in the end but

I want to get my last uploaded or current uploaded data in that table.

select * from Report where Report.DocumentID = ((SELECT Report.DocumentID from Report ORDER BY Report.DocumentID DESC))[0]

but this is giving error :slight_smile:

[
{
“code”: 4020,
“msg”: “Duplicate subquery alias Bilateral_Repo”,
“query_from_user”: “select * from Bilateral_Repo where Bilateral_Repo.DocumentID = ((SELECT Bilateral_Repo.DocumentID from Bilateral_Repo ORDER BY Bilateral_Repo.DocumentID DESC))[0]”
}
]

Hey @shalabh.negi,

I believe this is a simple case of the same query alias being used twice. Try giving your subquery a different table alias from the parent query, for instance:

select b.* from Bilateral_Repo b where b.DocumentID = ((SELECT a.DocumentID from Bilateral_Repo a ORDER BY a.DocumentID DESC))[0]

Cheers, Brett

1 Like

Thanks mate it worked flawless

Hi @shalabh.negi,

Check this out for more simple approach Query for latest records of a given set of users