Hacker News new | ask | show | jobs
by hotdamnson 1317 days ago
Why do these new big thing databases make SQL look like some witchcraft?

Here is some proper SQL query:

SELECT DISTINCT

       r.id,  

       r.owner_id,  

       r.name,  

       COUNT(r.id) OVER (PARTITION BY r.id) AS COUNT  

  FROM repository r  

  JOIN star s ON s.repository_id = r.id  
ORDER BY 4 DESC;
1 comments

This is not what the query in the post is doing.

You are counting all stars of all repos, they are counting stars of one (parameterized) repo id.

I just posted the essence of the query, add

Where r.id = :repo

and you will have the same thing.