How to query records located in one single note? (Using dataview)

Hello,
I am trying to query the data inside this note using dataview.
The following text is all inside one single note (one single .md file) named Testing dataview.md.

url:: https://github.com/theohbrothers/ConvertOneNote2MarkDown
name:: ConvertOneNote2MarkDown
stars:: 407
updated:: 2023-02-05

url:: https://github.com/ChristosMylonas/onenote2md
name:: onenote2md
stars:: 21
updated:: 2021-10-26

url:: https://github.com/SjoerdV/ConvertOneNote2MarkDown
name:: ConvertOneNote2MarkDown
stars:: 131
updated:: 2022-12-13 

url:: https://products.groupdocs.cloud/conversion/python/mht-to-md/
name:: mht-to-md

url:: https://github.com/alxnbl/onenote-md-exporter
name:: onenote-md-exporter
stars:: 383
updated:: 2022-10-26

What I’m trying to do

I want to create a simple table that list all the alternatives, sorted by number of stars.

Things I have tried

I had tried the following:

```dataview
TABLE WITHOUT ID name, stars, updated
FROM "Testing dataview.md"
WHERE stars != ""
SORT stars DESC
```

But it doesn’t sort by stars. Also, it does not work when some of the rows does not have value, for example, no stars value, will unsort the rows.

So, how to I create records inside one single note?
Why stars != "" is not working? I also tried stars != null. Also tried WHERE stars.
Why SORT stars DESC is not working?

Thanks!

This is because with a default dataview query you can only sort files, not information within one single file. You have to work with lists, I guess.

I played around with it a bit - as you want to query list items (in order to sort them), you have to collect all metadata that belong to the same item under a single bullet point:

* [url:: https://github.com/theohbrothers/ConvertOneNote2MarkDown] [name:: ConvertOneNote2MarkDown] [stars:: 407] [updated:: 2023-02-05]
* [url:: https://github.com/ChristosMylonas/onenote2md] [name:: onenote2md] [stars:: 21] [updated:: 2021-10-26]
* [url:: https://github.com/SjoerdV/ConvertOneNote2MarkDown] [name:: ConvertOneNote2MarkDown] [stars:: 131] [updated:: 2022-12-13] 
* [url:: https://products.groupdocs.cloud/conversion/python/mht-to-md/] [name:: mht-to-md] 
* [url:: https://github.com/alxnbl/onenote-md-exporter] [name:: onenote-md-exporter] [stars:: 383] [updated:: 2022-10-26]

The brackets are important, see here.

You dataview query then looks like this:

```dataview
TABLE WITHOUT ID L.name AS name, L.stars AS stars, L.updated AS updated
FROM "Testing dataview.md"
FLATTEN file.lists AS L
SORT L.stars DESC
1 Like

Thank you!

I had found an alternative to your solution.
Take a look at this:

- [url:: https://github.com/theohbrothers/ConvertOneNote2MarkDown]
    [name:: ConvertOneNote2MarkDown]
    [stars:: 407]
    [updated:: 2023-02-05]
- [url:: https://github.com/ChristosMylonas/onenote2md]
    [name:: onenote2md]
    [stars:: 21]
    [updated:: 2021-10-26]
- [url:: https://github.com/SjoerdV/ConvertOneNote2MarkDown]
    [name:: ConvertOneNote2MarkDown]
    [stars:: 131]
    [updated:: 2022-12-13] 
- [url:: https://products.groupdocs.cloud/conversion/python/mht-to-md/] 
    [name:: mht-to-md] 
- [url:: https://github.com/alxnbl/onenote-md-exporter] 
    [name:: onenote-md-exporter]
    [stars:: 383]
    [updated:: 2022-10-26]
- Some random text
    [url:: https://github.com/theohbrothers/Convert] 
    [name:: ConvertOn]
    [stars:: 2407]
    [updated:: 2023-02-28]

Also works with your query:

```dataview
TABLE WITHOUT ID L.name AS name, L.stars AS stars, L.updated AS updated
FROM "Testing.md"
FLATTEN file.lists AS L
SORT L.stars DESC
```

I get the expected result:

Thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.