Postgres Querying
This post contains some postgres querying and examples
We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
This blog post as a temporary place for interesting Postgres querying.
Some videos have no speaker names, because I have not added them so I need to exclude them from the query.
SELECT
speaker_name,
count(*) AS total_videos
FROM
all_events
WHERE
speaker_name != ''
GROUP BY
1
ORDER BY
total_videos DESC
LIMIT 10;
SELECT
*
FROM (
SELECT
id,
name,
slug,
count(1) OVER (PARTITION BY slug) AS Cnt
FROM
tags) a
WHERE
Cnt > 1;
SELECT * FROM videos WHERE title ~* 'keynote' AND provider == 'wwdc';
SELECT id, title FROM videos WHERE title ~* 'keynote' AND provider = 'wwdc';
SELECT pg_size_pretty( pg_database_size('dbname') );
SELECT name, count(*) total_tags
FROM tags
JOIN videos_tags on videos_tags.tag_id = tags.id
GROUP by tags.id
ORDER by total_tags desc;
select name, count(*) total
from speakers
join videos_speakers on videos_speakers.speaker_id = speakers.id
group by speakers.id
order by total desc
limit 10;