#22 The PADS | HackerRank SQL Solutions
ฝัง
- เผยแพร่เมื่อ 6 ต.ค. 2024
- #SQL #MYSQL #DATABASE #SELECT #hackerrank #C #C++ #JAVA
SELECT *
FROM DEV19;
*Keep Studying...
Code is here :
dev19community...
Please follow us
/ dev.19.community
Thanks for watching us ...
Dev19🖤 - วิทยาศาสตร์และเทคโนโลยี
Those who are watching this now this query won't work as we have to now use UNION between two select statements otherwise second statement's select part will come into output . Also we can only use one order by after using union .
This is the query that will work--
select concat(name,'(',left(occupation,1),')') as ZZZ from occupations
UNION ALL
select concat('There are a total of ',count(occupation),' ',lower(occupation),'s.') from occupations group by occupation order by ZZZ ;
SELECT CONCAT(Name,"(", LEFT(Occupation,1),")")
FROM OCCUPATIONS
UNION
SELECT CONCAT("There are a total of ",COUNT(*)," ",LOWER(Occupation),"s.")
FROM OCCUPATIONS
GROUP BY Occupation
ORDER BY 1
@@naumanbabar7240 thank you. it is helpful.
@@naumanbabar7240 Why did you use Order by 1?
It's working brother
whatever solution provided on video is working
select name || '(' || substr(occupation, 1, 1) || ')' as name_occupation
from occupations
order by name;
select 'There are a total of ' || count(occupation) || ' ' || lower(occupation) || 's.'
from occupations
group by occupation
order by count(occupation),occupation asc;
Thanks.The series has been very very helpful.
sir I am trying to get a job as Data Analyst and learning all the things from only TH-cam and I am from a non tech background . I have done some basic python , sql , pandas , numpy , matplotlib and seaborn libraries from youtube only and now trying to solve questions on SQL from hackerrank so are these questions enough to give me enough practice to crack interviews on SQL only ?
as Fresher these things are enough, If u think ur basics are now at some good level, try giving interviews bcoz interviews will give u lot of experience
@siddheshshinde4805 bro can Please Recommend me TH-cam Channels for Learning Python Libraries those You Mentioned Above.
@@chetanreddy2076 freecodecamp
Great but why u used order by count(occupation), occupation at the end what it is used for
Getting error with code you have provided
Select Concat(name, "(",left(name,1),")") from occupations order by name;
I am getting an error for the same query
SELECT concat(Name, '(',LEFT(Occuaption,1),')')
FROM OCCUPATIONS
ORDER BY Name;
SELECT concat('There are a total of ',count(Occupation),' ',lower(Occupation), 's.')
FROM OCCUPATIONS
GROUP BY Occupation
ORDER BY count(Occupation), Occupation
I am getting an error. But can't find any error.
try this
SELECT CONCAT(Name,"(", LEFT(Occupation,1),")") FROM OCCUPATIONS
UNION
SELECT CONCAT("There are a total of ",COUNT(*)," ",LOWER(Occupation),"s.")
FROM OCCUPATIONS
GROUP BY Occupation ORDER BY 1
@@anonymousboy9511 order by 1, how it works??