You can translate the question and the replies:

Create a Selection View and get only the first 2 records

Hello I want to create a selection view of a derived view that has a column "date" (localdate), and in this selection view I waht to order by date desc, and I only need the first 2 records. How can I do that in denodo? I have this record: 2019-12-01 2019-11-01 2019-10-01 2019-09-01 2019-08-01 2019-07-01 2019-06-01 2019-05-01 And I need the 2 first reords. Or The last two months.
user
05-02-2020 09:25:41 -0500
code

3 Answers

Hi, For this scenario, I would perform the following steps in Virtual DataPort Administration Tool to get the required results: * First, I would create a [Selection](https://community.denodo.com/docs/html/browse/7.0/vdp/administration/creating_derived_views/creating_selection_views/creating_selection_views) view over the view that has the dates. * Under *Where Conditions* tab of the above created Selection view, I would add a simple condition by selecting the date field to be greater than '2019-10-01' `For example: "DATEINFO"."DA" > '2019-10-01'` * Then, to add the ORDER BY, I would navigate to *Output* tab of the created Selection view, add the date column name as the value to the ORDER BY field and then click the green plus to select DESC from drop down. * Save and execute the view to get only the first two records (i.e., 2019-12-01, 2019-11-01 ) Hope this helps!
Denodo Team
06-02-2020 07:10:09 -0500
code
Thank you for your answer, but the problem is that the dates could change
user
06-02-2020 07:14:09 -0500
Hi, If the base view has the dates value like "*2019-05-01,2019-06-01,2019-07-01.....*" and after I create a Selection view to add the *ORDER BY* to be in **DESC** order like "2019-12-01,2019-11-01,2019-10-01...." without any where conditions. Then, even if the date set gets updated with new values, I would still be able to get the latest records (i.e.,"*2020-02-01,2020-01-01,2019-12-01....*") by navingating to "*Execute>Quick Query* tab" and clicking on the "Display rows" to be 2 in the created selection view or by using the [FETCH](https://community.denodo.com/docs/html/browse/7.0/vdp/vql/queries_select_statement/offset_fetch_and_limit/offset_fetch_and_limit) command to the derived view in the VQL Shell. Hope this helps!
Denodo Team
13-02-2020 07:32:36 -0500
code
You must sign in to add an answer. If you do not have an account, you can register here