Dataview Question: Sort groups when using GroupBy

Things I have tried

I’ve searched both this forum and the subreddit. I found this post, but the solution there (GROUP BY “FORMER” AS “LATTER”) didn’t seem to work either

What I’m trying to do

I’ve got these notes for books, where I define authors.

In a separate note, I made a table where I want to see the authors and how many books of them I have in my vault. I managed that part.

But now I would like to sort the list of authors alphabetically, and somehow that doesn’t seem to work.

Here’s my current query (“Schrijver” is Dutch for author):

TABLE WITHOUT ID Schrijver, length(rows) as "Aantal boeken"
FROM "Referentie/Boeken"
FLATTEN Schrijver
SORT Schrijver ASC
GROUP BY Schrijver

Any help is most welcome!

1 Like

Topic

Summary

Q: What does the following DQL10 statement mean?


DQL10_flatten_groupBy_sort_and_TABLE

Summary

Main DQL

# Code Data type In English Remark
1 TABLE WITHOUT ID 1.1 To display the result as a table
1.2 Not To display the default ID columns, File or Group
2 GF_Schrijver AS “Schrijver”, a list 2.1 To display the content of a field variable GF_Schrijver
2.2 To display the field label as “Schrijver”
3 length(rows) AS “Aantal boeken” a list 3.1 To display the content of a field expression like length(rows)
3.2 To display the field label as “Aantal boeken”
“Aantal boeken”
=“quantity of the books”
4 FROM “Referentie/Boeken” FROM the Folder : “Referentie/Boeken” “boeken” = “book”
5 WHERE Schrijver != null a list WHERE Schrijver does not strictly equal null “Schrijver” = “Writer”
7
8 FLATTEN Schrijver AS F_Schrijver a list=>a non-list 8.1 To break up a list like Schrijver in a file into each individual element in a file
8.2 To define a field variable F_Schrijver as each element of Schrijver of each note
8.2.1 let F_Schrijver = each element of Schrijver of each page;
9 WHERE F_Schrijver != null a non-list WHERE F_Schrijver does not strictly equal null
10 SORT F_Schrijver ASC a non-list To sort by F_Schrijver in ascending order
11 GROUP BY F_Schrijver AS GF_Schrijver a non-list=>a list 11.1 To group by F_Schrijver
11.2 let GF_Schrijver = rows.F_Schrijver;
12 SORT GF_Schrijver DESC a list To sort by GF_Schrijver in descending order

DQL10_flatten_groupBy_sort_and_TABLE

Summary_code
title: DQL10_flatten_groupBy_sort_and_TABLE => 
collapse: close
icon: 
color: 
```SQL
TABLE WITHOUT ID 
      GF_Schrijver AS "Schrijver", 
      length(rows) AS "Aantal boeken"
FROM "Referentie/Boeken"
WHERE Schrijver != null

FLATTEN Schrijver AS F_Schrijver
WHERE F_Schrijver != null
SORT F_Schrijver ASC
GROUP BY F_Schrijver AS GF_Schrijver
SORT GF_Schrijver DESC
```


Reference

Summary
  • Dataview Snippet Showcase: using a single Dataview inline field as a row of a table in the file

I ended up with

table without id key AS Schrijvers, length(rows) as "Aantal boeken" 
from "Hobby's & Interesses/Lezen" 
group by Schrijver 
sort key asc

somehow this worked…

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