Closed simonw closed 3 months ago
Could look like this:
sqlite-utils ask tils.db 'posts per year'
SELECT strftime('%Y', created) AS year, COUNT(*) AS posts_count
FROM til
GROUP BY year
Results:
[
{
"year": "2020",
"posts_count": 100
},
{
"year": "2021",
"posts_count": 125
},
{
"year": "2022",
"posts_count": 140
},
{
"year": "2023",
"posts_count": 117
},
{
"year": "2024",
"posts_count": 41
}
]
I simplified it to:
SELECT strftime('%Y', created) AS year, COUNT(*) AS posts_count
FROM til
GROUP BY year;
[
{
"year": "2020",
"posts_count": 100
},
{
"year": "2021",
"posts_count": 125
},
{
"year": "2022",
"posts_count": 140
},
{
"year": "2023",
"posts_count": 117
},
{
"year": "2024",
"posts_count": 41
}
]
Is Markdown a good default output format? How should the data itself be presented?
I find JSON more readable in the terminal than tables, due to width restraints.
The problem is you really need to be able to see both the SQL and the results, and potentially any commentary as well.