Skip to content

Commit

Permalink
More interesting example SQL query
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw authored Dec 21, 2023
1 parent 56b6521 commit 1ea9f08
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions sqlite/steampipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,34 @@ order by not_after desc;
```
![Screenshot of Datasette running that SQL query. The top results are lambda-demo.datasette.io 2024-10-01 sqlite-utils.datasette.io 2024-09-27 sqlite-utils.datasette.io 2024-09-27 docs.datasette.io 2024-05-13 docs.datasette.io 2024-05-13 shot-scraper.datasette.io 2024-04-17 shot-scraper.datasette.io 2024-04-17](https://static.simonwillison.net/static/2023/steampipe-crt-datasette.jpg)

Here's a more interesting query, returning my most recent Hacker News comments demonstrating a CTE, JSON processing and a join across two virtual tables:

```sql
with post_ids as (
select
value
from
json_each(submitted),
hackernews_user
where
hackernews_user.id = 'simonw'
limit
20
)
select
*
from
hackernews_item
where
hackernews_item.id in (
select
value
from
post_ids
)
order by time desc
```

Here's more detailed documentation of the kind of queries you can now run:

- [Tables in crt.sh](https://hub.steampipe.io/plugins/turbot/crtsh/tables)
Expand Down

0 comments on commit 1ea9f08

Please sign in to comment.