LeetCode 1667: Fix Names in a Table [SQL]
11:38
LeetCode 1341: Movie Rating [SQL]
18:35
16 сағат бұрын
LeetCode 1193: Monthly Transactions I
17:16
LeetCode 1075: Project Employees I
5:54
LeetCode 1251: Average Selling Price
13:19
Пікірлер
@sachin-b8c4m
@sachin-b8c4m Күн бұрын
thank you
@sachin-b8c4m
@sachin-b8c4m Күн бұрын
thank you
@kamaldeepsingh810
@kamaldeepsingh810 2 күн бұрын
I stated my SQL journey pretty recently and of all the people who provide solutions on internet YOU ARE THE BEST!!! Your videos help build the intuition and thinking while writing the queries rather than just cramming up code. Thanks Frederik.
@frederikmuller
@frederikmuller 2 күн бұрын
Awesome! I put a lot of care in making things clear for beginners and try to talk about how to get to the solution instead of just how the solution works. I’m glad you noticed that and it’s helpful. Good luck on your SQL journey!
@sachin-b8c4m
@sachin-b8c4m 4 күн бұрын
thank you
@frederikmuller
@frederikmuller 4 күн бұрын
thank you for watching so many videos!
@sachin-b8c4m
@sachin-b8c4m 4 күн бұрын
thank you
@sachin-b8c4m
@sachin-b8c4m 4 күн бұрын
thank you
@sachin-b8c4m
@sachin-b8c4m 4 күн бұрын
thank you
@sachin-b8c4m
@sachin-b8c4m 5 күн бұрын
thank you
@hazard_2444
@hazard_2444 5 күн бұрын
Repeatedly was getting errors, figured out I missed the important point that product_key can be repeated for a particular customer as it's a foreign key
@frederikmuller
@frederikmuller 4 күн бұрын
Exactly, they could buy a product more than once. Thanks for sharing.
@sachin-b8c4m
@sachin-b8c4m 8 күн бұрын
thank you
@IgorOliveira-nh5pc
@IgorOliveira-nh5pc 10 күн бұрын
Great content, im trying to get better at sql and this channel is showing me exactly what not to do (just kidding folk, you great!
@sachin-b8c4m
@sachin-b8c4m 10 күн бұрын
thank you
@robbiedeegan3121
@robbiedeegan3121 11 күн бұрын
Thank you! Learned something new 😃
@j.b.1342
@j.b.1342 14 күн бұрын
Great idea! Thanks for the motivation to get this done!
@HenggaoCai
@HenggaoCai 15 күн бұрын
There is an extra parathesis.
@frederikmuller
@frederikmuller 15 күн бұрын
yes, it’s left over from the previous calculation where I used another pair of parentheses
@HenggaoCai
@HenggaoCai 15 күн бұрын
month is an alias.
@frederikmuller
@frederikmuller 15 күн бұрын
I agree, it’s best to put it in quotes as it’s an SQL keyword for date formatting. In MySQL, it works without quotes.
@ujjwaldhawa6468
@ujjwaldhawa6468 17 күн бұрын
Hi Frederik..very good explanation..
@frederikmuller
@frederikmuller 17 күн бұрын
Thank you, means a lot!
@andresjvazquez
@andresjvazquez 19 күн бұрын
🚀
@BJ_2311
@BJ_2311 19 күн бұрын
yo
@frederikmuller
@frederikmuller 15 күн бұрын
yooo!
@debdeepdhar2534
@debdeepdhar2534 20 күн бұрын
In case of a tie the rank window function would have the same output for the rows. Since the question asked that the ranks be unique you should use Row_number function instead
@frederikmuller
@frederikmuller 20 күн бұрын
You’re technically right but this question has some specific details. The ranks will be unique in my solution since I’m adding from_user to the ORDER BY statement in the window function clause. from_user is a unique id and part of our GROUP BY. The question specifically mentions using the alphabetical order of the user name as a tiebreaker. If you were just using UNIQUE_RANK() without specifying from_user the order of tied users may be random depending on the order of the input data.
@PratikPratik-e6n
@PratikPratik-e6n 20 күн бұрын
Let's go
@andresjvazquez
@andresjvazquez 20 күн бұрын
You're back ! Yay! Happy to support you if u have a Patreon
@frederikmuller
@frederikmuller 20 күн бұрын
aren’t you still in high school judging from your past comments? I’m sure there are better ways to spend your money at that age 😅 Thanks for watching!
@sachin-b8c4m
@sachin-b8c4m 21 күн бұрын
Happy to see you back after 5 months
@frederikmuller
@frederikmuller 20 күн бұрын
Thank you! I've been uploading some shorts on the channel in the last few months, feel free to check them out.
@sachin-b8c4m
@sachin-b8c4m 24 күн бұрын
thank you
@frederikmuller
@frederikmuller 20 күн бұрын
You're welcome!
@balaji27venkatesh
@balaji27venkatesh 25 күн бұрын
premium subscription required for this
@frederikmuller
@frederikmuller 25 күн бұрын
There’s a sale going on right now!
@balaji27venkatesh
@balaji27venkatesh 25 күн бұрын
-- efficient code select c.name as "Customers" from Customers as c left join Orders as o on c.id = o.customerId where o.id is null ---- simple to understand but not efficient code select name as "Customers" from Customers where id not in (select distinct Customerid from Orders)
@frederikmuller
@frederikmuller 25 күн бұрын
I see you’re solving a lot of questions on this channel, keep it up.
@balaji27venkatesh
@balaji27venkatesh 25 күн бұрын
-- Write your PostgreSQL query statement below select max(salary) as SecondHighestSalary from Employee where salary < (select max(salary) from Employee)
@balaji27venkatesh
@balaji27venkatesh 25 күн бұрын
select firstName, lastName, city, state from Person as p left join Address as a on p.personId = a.personId
@balaji27venkatesh
@balaji27venkatesh 25 күн бұрын
select event_day as day, emp_id, sum(out_time - in_time) as total_time from Employees group by 1,2
@sachin-b8c4m
@sachin-b8c4m 27 күн бұрын
thank you please continue making videos
@sachin-b8c4m
@sachin-b8c4m 27 күн бұрын
thank you please continue making videos
@sachin-b8c4m
@sachin-b8c4m 27 күн бұрын
thank you
@sachin-b8c4m
@sachin-b8c4m 28 күн бұрын
this is very helpful, thanks for sharing
@sachin-b8c4m
@sachin-b8c4m Ай бұрын
thanks for the video but i solved the problem with if select sum(boxes.apple_count + if(chests.apple_count is null,0,chests.apple_count)) as apple_count, sum(boxes.orange_count + if(chests.orange_count is null, 0,chests.orange_count )) as orange_count from boxes left join chests on boxes.chest_id = chests.chest_id
@spamixofficial
@spamixofficial Ай бұрын
I’m a programmer (not doing any data stuff) and it was really nice to get an insight to what people choose and why data-analysis wise. Thanks!
@frederikmuller
@frederikmuller Ай бұрын
I started out as a programmer myself! Great to hear you were able to take something away from the video.
@boredperson82
@boredperson82 Ай бұрын
why are we selecting event_date in subquery?
@abhishekpandey190
@abhishekpandey190 Ай бұрын
What is issue in this Ms SQL server (output is same except order) >> Select v.customer_id,count(v.visit_id) as count_no_trans from Visits as v right join Transactions as t on t.Visit_id=v.Visit_id where t.transaction_id is null group by v.customer_id
@sachin-b8c4m
@sachin-b8c4m Ай бұрын
you videos are very helpful, kindly continue making videos .
@SomeRandomName999999
@SomeRandomName999999 2 ай бұрын
Why sum(b.weight) instead of (a.weight)?
@sachin-b8c4m
@sachin-b8c4m 2 ай бұрын
thanks
@sachin-b8c4m
@sachin-b8c4m 2 ай бұрын
thank you
@ANKITSINGH-fz3ft
@ANKITSINGH-fz3ft 3 ай бұрын
why can't i use this solution : gives correct answer but not accepted select product_id, min(year) as first_year, quantity, price from Sales group by product_id what is wrong with it?
@frederikmuller
@frederikmuller 3 ай бұрын
you pull the minimum year but the values for first_year, quantity and price won’t necessarily be from the minimum year. it will just give you the first values in the table.
@newtc93
@newtc93 3 ай бұрын
ure amazing
@frederikmuller
@frederikmuller 3 ай бұрын
no u
@giannizifarelli3060
@giannizifarelli3060 3 ай бұрын
Hi! Can anyone help me understand why the following code returns 2 products? SELECT p.product_id, p.product_name FROM product p JOIN sales s ON s.product_id=p.product_id WHERE s.sale_date NOT BETWEEN '2019-04-01' AND '2019-12-31' GROUP BY p.product_id
@frederikmuller
@frederikmuller 3 ай бұрын
Your query allows for sales in other years than 2019. Also it doesn’t account for the product ONLY selling in spring 2019.
@HelloIamLauraa
@HelloIamLauraa 3 ай бұрын
i didn't hear about this page yet
@frederikmuller
@frederikmuller 3 ай бұрын
you should give it a try!
@HelloIamLauraa
@HelloIamLauraa 3 ай бұрын
@@frederikmuller are there also nlp, ML questions or more like db and sql interview question?
@aliebi13
@aliebi13 4 ай бұрын
WOW This is an efficient code😍
@curiously-cinnamon
@curiously-cinnamon 4 ай бұрын
This is the first question in SQL 50 that I wasn't able to solve right away. Thanks for your helpful video. Now I know how to approach these kinds of problems
@sabisingh9635
@sabisingh9635 4 ай бұрын
Why is it a sum and not count in your query? Aren’t we counting number of cancelled rides ??
@frederikmuller
@frederikmuller 4 ай бұрын
a SUM still works here as the IF statement within the SUM function gives 1 for cancelled rides, that way we’re summing up or counting the cancelled rides. you could also use COUNT if you restructure the IF statement to assign NULL to non-cancelled rides.
@Savenature635
@Savenature635 4 ай бұрын
here is my approach in mysql : with cte as(select order_id,customer_id,order_date,a.item_id,item_category,quantity,dayname(order_date) as dayname from amazon_orders a left join amazon_items i on a.item_id=i.item_id) select item_category, sum(case when item_category in ('book','phone','glasses') and dayname='Monday' then quantity else 0 end) as 'Monday', sum(case when item_category in ('book','phone','glasses') and dayname='Tuesday'then quantity else 0 end) as 'Tuesday', sum(case when item_category in ('book','phone','glasses') and dayname='Wednesday' then quantity else 0 end) as 'Wednesday', sum(case when item_category in ('book','phone','glasses') and dayname='Thursday' then quantity else 0 end) as 'Thursday', sum(case when item_category in ('book','phone','glasses') and dayname='Friday' then quantity else 0 end) as 'Friday', sum(case when item_category in ('book','phone','glasses') and dayname='Saturday' then quantity else 0 end) as 'Saturday', sum(case when item_category in ('book','phone','glasses') and dayname='Sunday' then quantity else 0 end) as 'Sunday' from cte group by 1;