Hey there! 👋 For more interesting content, tutorials, and updates, Feel free to connect with me on Instagram Handles :- @createwithchirag - instagram.com/createwithchirag/ @learn.with.chirag - instagram.com/learn.with.chirag/ LinkedIn: www.linkedin.com/in/chirag-sehgal-9200111b8/ Let's stay connected and keep the creativity flowing! 💡
@arshlankhan150710 ай бұрын
why we did not use right join in this qus ? explain please
@swatiriyal924210 ай бұрын
Easiest solution i could find on internet, Good work sir!
@learnwithchirag10 ай бұрын
Glad it helped !..Keep Learning 💯🎯
@justcodeitbro13125 ай бұрын
if we are using group by then it will count the number of user_id in each group right ? no need of distinct worked for me without it
@rishavrajsingh7660Ай бұрын
hello I'm having one question why you didn't use the join and how its even possible without join function?
@skkrrtt2344Ай бұрын
# Write your MySQL query statement below SELECT r.contest_id, ROUND(COUNT(DISTINCT user_id)*100/(SELECT COUNT(user_id) from Users),2) as percentage FROM Users as u RIGHT JOIN Register as r USING(user_id) GROUP BY contest_id ORDER BY percentage DESC,r.contest_id; My solution
@Nik_vlogs15 ай бұрын
Thanks very helpful
@abhishekdhakne4879 Жыл бұрын
why didn't we use JOIN
@learnwithchirag Жыл бұрын
Yes , There can be multiple ways of solving an SQL question. Here is the query using JOIN- SELECT r.contest_id, ROUND((SUM(IF(r.user_id IS NOT NULL, 1, 0)) / (SELECT count(*) FROM users) * 100), 2) AS percentage FROM Register r LEFT JOIN users u ON u.user_id = r.user_id GROUP BY r.contest_id ORDER BY percentage DESC, r.contest_id ASC; The choice between using a join or not depends on the specific requirements of your query and the structure of your database. Both approaches are valid, and you should choose the one that best fits your needs and performs well with your database schema and data distribution.
@akhilpratapsingh3223 Жыл бұрын
In this we should use right join na?@@learnwithchirag
@sandhyarawat176811 ай бұрын
sir (SELECT count(*) FROM users) ki place me count(u.user_name) ya u.user_id likh sakte hai kya???? nahi to kyu nahi
@sandeepvarma8911 ай бұрын
@@sandhyarawat1768kar sakte hai dono ka answer same hi aayega count (*)from users Kiya toh total rows count honge jo hai 3, user_name count Kiya toh bhi 3 hi aayega,user_id bhi use kar sakte hai
@redeagle6580 Жыл бұрын
invalid use of group by de rha
@learnwithchirag11 ай бұрын
Please do check your syntax again. The query is working perfectly fine for me !
@karunakarverma64674 ай бұрын
TLE mar gya ye to
@muhibajaz71563 ай бұрын
Solve this query with Join: SELECT r.contest_id, ROUND(COUNT(r.user_id) / (SELECT COUNT(*) FROM Users) * 100, 2) AS percentage FROM Register r LEFT JOIN Users u ON u.user_id = r.user_id GROUP BY r.contest_id ORDER BY percentage DESC, r.contest_id ASC;
@abhijaychouhan51762 ай бұрын
SELECT contest_id, ROUND(COUNT(contest_id)*100/(SELECT COUNT(user_id) FROM Users), 2) AS percentage FROM Register GROUP BY contest_id ORDER BY percentage DESC, contest_id This code is running fine , even if I changed this "distinct user_id" to "contest_id" and why this code is more optimised HELP ME