S
S
Sergey Beloventsev2017-09-19 20:23:54
MySQL
Sergey Beloventsev, 2017-09-19 20:23:54

What should be added to the request to get the number of defined values?

Here is such a request

SELECT "bonus", (nlevel(tree_path) - nlevel('2.383')) as nl,count(nl)
FROM "user" 
INNER JOIN "user_bonus_item" 
ON user_id_from = "user".id 
WHERE ("tree_path" ~ '2.383.*{0,5}')
AND user_id_to = user_id_from 
AND ("user_bonus_item"."mounth_bonus" = '9:2017') 
AND ("bonus" > 50) 
ORDER BY "nl";

get
bonus  | nl 
--------+----
 305.00 |  0
  52.00 |  1
  52.00 |  1
  51.00 |  1
  52.00 | 2
   60.00| 3

tell me what else I need to add to the request in order to get the number of nl which are equal to 1

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question