Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I need to get the numbers of Users for each language

I have a list of languages and I need to show how many users subscribe to each.

I work on my project with Angular 13 and AsP.net Core 6 and SQLServer but
there are two blocked ways

  1. Use angular services in NgFor but return infinite loops and crash.

    MEDevel.com: Open-source for Healthcare and Education

    Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

    Visit Medevel

  2. Use .NET to return the list of languages and loop a second query to get count users but not work.

  3. the last is to Create something with SQLSever ( I don’t know how )

[Table languages][1]

table users

>Solution :

In your API you will need to return a payload that you can use to show the results you expect. From the API layer, you need to access the database and transform data to the meet the former challenge. The query to obtain the results is rather straightforward.

SELECT 
    L.lang_id,
    L.title,
    L.description,
    L.image,
    COUNT(*) as UserCount
FROM
    Languages L
    INNER JOIN Users U on U._id_lang = L.id_lang
GROUP BY
    L.id_lang 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading