Computer Science, asked by hinachute19, 9 months ago

java program for In this MySQL challenge, your query should return the current 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 consolidate the rows to be grouped by FirstName, and a Count column should be added at the end that adds up the number of times that person shows up in the table. The output table should then be sorted by the Count column in ascending order. Your output should look like the following table.

Answers

Answered by sakshisharmaa16
0

Answer:

hope this helps you

Explanation:

You need to count the value of the column value for each id:

select

t.id,

(select count(*) from tablename where value = t.value) count

from tablename t

See the demo

or:

select t.id, g.count

from tablename t inner join (

select value, count(value) count

from tablename

group by value

) g on g.value = t.value

See the demo

In MySQL versions without window functions, you can achieve the results you want with a self join on value, counting the number of values in the second table:

SELECT t1.id, COUNT(t2.value) AS cnt

FROM table1 t1

JOIN table1 t2 ON t2.value = t1.value

GROUP BY t1.id

Output:

id cnt

1 2

2 2

3 1

4 1

Similar questions