1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Regarding SQL Inner Join

Discussão em 'Outras Linguagens' iniciado por Stack, Fevereiro 3, 2021.

  1. Stack

    Stack Membro Participativo

    The question is as follows :

    Final query should return the vendor information along with the values from the table cb_vendorinformation.

    You should combine the values of the two tables based on the GroupID column.

    The final query should only print out the GroupID, CompanyName, and final count of all rows that are grouped into each company name under a column titled Count.

    The output table should be then sorted by the Count column and then sorted by GroupID so that a higher number appears first.

    This is the main table :

    maintable

    The output should look like this :

    finaloutput

    I could develop a code as follows but I am not getting the correct output :

    SELECT m.GroupID, c.CompanyName, Count(*) as count
    FROM maintable_KN01N m
    INNER JOIN cb_vendorinformation c ON m.GroupID = c.GroupID


    My output : my output

    Expected output : expected output

    Could someone please help me out here ?

    I tried this code :

    SELECT m.GroupID
    , c.CompanyName
    , Count(*) as count
    FROM maintable_KN01N m
    JOIN cb_vendorinformation c
    ON m.GroupID = c.GroupID
    GROUP
    BY m.GroupID
    , c.CompanyName;


    And was getting the output as follows :

    Output2

    Continue reading...

Compartilhe esta Página