---
title: "Comment by Malakar Rakesh on \"From SQL to NoSQL world!\" | Hashnode"
description: "Nice article! The query can also be written as: SELECT actor_name AS actorName, Sum ( CASE WHEN acr.rating_name = &#x27;excellent&#x27; THEN 1 ELSE 0 END ) AS t"
url: "https://hashnode.com/posts/from-sql-to-nosql-world/5ff9ce2aaa5c467fe155896b/comment/5ffe9966c162d710c9b1389b"
---

[Discussion](https://hashnode.com/posts/from-sql-to-nosql-world/5ff9ce2aaa5c467fe155896b)

Comment [From SQL to NoSQL world!](https://hashnode.com/posts/from-sql-to-nosql-world/5ff9ce2aaa5c467fe155896b)

[Malakar Rakesh](https://hashnode.com/@malakarakesh)

[Jan 13, 2021](https://hashnode.com/posts/from-sql-to-nosql-world/5ff9ce2aaa5c467fe155896b/comment/5ffe9966c162d710c9b1389b)

Nice article!

The query can also be written as:

```
SELECT actor_name AS actorName, 
       Sum(CASE 
             WHEN acr.rating_name = 'excellent' THEN 1 
             ELSE 0 
           END)   AS total_excellent, 
       Sum(CASE 
             WHEN acr.rating_name = 'better' THEN 1 
             ELSE 0 
           END)   AS total_better, 
       Sum(CASE 
             WHEN acr.rating_name = 'good' THEN 1 
             ELSE 0 
           END)   AS total_good 
FROM   actor_survey acs 
       LEFT JOIN actor_rating acr 
              ON acs.rating_id = acr.id 
GROUP  BY actorname
```

But I understand the posted query is for the sake of the purpose of this article series. :D

[Manish Basnet](https://hashnode.com/@manishbasnet)

[Jan 13, 2021](https://hashnode.com/posts/from-sql-to-nosql-world/5ff9ce2aaa5c467fe155896b/comment/5ffe9966c162d710c9b1389b#reply-5ffec60dc162d710c9b13d67)

This looks better. Thank you! I will go through it again.
