Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Basic CTEs
16. Exercise 2


Excellent. You should now be ready to solve the more difficult question.


Among successful projects, those that raised 100% to 150% of the minimum amount are good projects, whereas those that raised more than 150% are great projects. Show the number of projects (name the column Count) along with a string representing how good the project is (good projects or great projects). Name that column Tag.

The result should look similar to this:

Count Tag
16 Good projects
7 Great projects

The second column should be of the nvarchar type.

Stuck? Here's a hint!

You will need two CTEs: one for those projects which raised 100-150% and another one for those which raised more than 150%. Use HAVING clauses to check the conditions. Use UNION ALL to show the results from both queries.

To create the Tag column use:

N'Good projects' AS Tag


N'Great projects' AS Tag

Mind the N – the column should be of the nvarchar type.