T
T
tiakuv2019-12-12 11:39:53
SQL
tiakuv, 2019-12-12 11:39:53

Counting and grouping in hierarchy (Sqlite)?

There are 2 tables.
1st is a hierarchical structure and looks like this:
code | parent | level
001 | | 1
001.1 | 001 | 2
001.1.1 | 001.1 | 3
001.2 | 001 | 2001.3
| 001 | 2
2nd contains articles and column code (refers to the 1st table)
I want to display the codes of the 2nd level and the number of articles with the corresponding codes, so that the articles of all child codes are taken into account in the calculation.
I understand that you need to use WITH, GROUP BY and probably JOIN. I try, but something does not work out
Thank you.

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