## FROM
The `FROM` statement determines what pages will initially be collected and passed onto the other commands for further filtering. You can select from any [source](https://blacksmithgu.github.io/obsidian-dataview/queries/reference/sources), which currently means by folder, by tag, or by incoming/outgoing links.
- **Tags**: To select from a tag (and all its subtags), use `FROM #tag`.
- **Folders**: To select from a folder (and all its subfolders), use `FROM "folder"`.
- **Single Files**: To select from a single file, use `FROM "path/to/file"`.
- **Links**: You can either select links TO a file, or all links FROM a file.
- To obtain all pages which link TO `[[note]]`, use `FROM [[note]]`.
- To obtain all pages which link FROM `[[note]]` (i.e., all the links in that file), use `FROM outgoing([[note]])`.
## WHERE Examples
Filter pages on fields. Only pages where the clause evaluates to `true` will be yielded.
`WHERE <clause>`
Obtain all files which were modified in the last 24 hours:
```
LIST WHERE file.mtime >= date(today) - dur(1 day)
```
Find all projects which are not marked complete and are more than a month old:
```
LIST
FROM #projects
WHERE !completed AND file.ctime <= date(today) - dur(1 month)
```
## SORT Examples
Sorts all results by one or more fields.
`SORT field [ASCENDING/DESCENDING/ASC/DESC]`
You can also give multiple fields to sort by. Sorting will be done based on the first field. Then, if a tie occurs, the second field will be used to sort the tied fields. If there is still a tie, the third sort will resolve it, and so on.
`SORT field1 [ASCENDING/DESCENDING/ASC/DESC], …, fieldN [ASC/DESC]`
## GROUP BY Examples
Group all results on a field. Yields one row per unique field value, which has 2 properties: one corresponding to the field being grouped on, and a `rows` array field which contains all of the pages that matched.
`GROUP BY field GROUP BY (computed_field) AS name`
In order to make working with the `rows` array easier, Dataview supports field "swizzling". If you want the field `test` from every object in the `rows` array, then `rows.test` will automatically fetch the `test` field from every object in `rows`, yielding a new array. You can then apply aggregation operators like `sum()` or `flat()` over the resulting array.
## FLATTEN Examples
Flatten an array in every row, yielding one result row per entry in the array.
`FLATTEN field FLATTEN (computed_field) AS name`
For example, flatten the `authors` field in each literature note to give one row per author:
Query
`TABLE authors FROM #LiteratureNote FLATTEN authors`
## LIMIT Examples
Restrict the results to at most N values.
`LIMIT 5`
Commands are processed in the order they are written, so the following sorts the results _after_ they have already been limited:
`LIMIT 5 SORT date ASCENDING`