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.
@frederikmuller2 күн бұрын
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-b8c4m4 күн бұрын
thank you
@frederikmuller4 күн бұрын
thank you for watching so many videos!
@sachin-b8c4m4 күн бұрын
thank you
@sachin-b8c4m4 күн бұрын
thank you
@sachin-b8c4m4 күн бұрын
thank you
@sachin-b8c4m5 күн бұрын
thank you
@hazard_24445 күн бұрын
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
@frederikmuller4 күн бұрын
Exactly, they could buy a product more than once. Thanks for sharing.
@sachin-b8c4m8 күн бұрын
thank you
@IgorOliveira-nh5pc10 күн бұрын
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-b8c4m10 күн бұрын
thank you
@robbiedeegan312111 күн бұрын
Thank you! Learned something new 😃
@j.b.134214 күн бұрын
Great idea! Thanks for the motivation to get this done!
@HenggaoCai15 күн бұрын
There is an extra parathesis.
@frederikmuller15 күн бұрын
yes, it’s left over from the previous calculation where I used another pair of parentheses
@HenggaoCai15 күн бұрын
month is an alias.
@frederikmuller15 күн бұрын
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.
@ujjwaldhawa646817 күн бұрын
Hi Frederik..very good explanation..
@frederikmuller17 күн бұрын
Thank you, means a lot!
@andresjvazquez19 күн бұрын
🚀
@BJ_231119 күн бұрын
yo
@frederikmuller15 күн бұрын
yooo!
@debdeepdhar253420 күн бұрын
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
@frederikmuller20 күн бұрын
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-e6n20 күн бұрын
Let's go
@andresjvazquez20 күн бұрын
You're back ! Yay! Happy to support you if u have a Patreon
@frederikmuller20 күн бұрын
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-b8c4m21 күн бұрын
Happy to see you back after 5 months
@frederikmuller20 күн бұрын
Thank you! I've been uploading some shorts on the channel in the last few months, feel free to check them out.
@sachin-b8c4m24 күн бұрын
thank you
@frederikmuller20 күн бұрын
You're welcome!
@balaji27venkatesh25 күн бұрын
premium subscription required for this
@frederikmuller25 күн бұрын
There’s a sale going on right now!
@balaji27venkatesh25 күн бұрын
-- 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)
@frederikmuller25 күн бұрын
I see you’re solving a lot of questions on this channel, keep it up.
@balaji27venkatesh25 күн бұрын
-- Write your PostgreSQL query statement below select max(salary) as SecondHighestSalary from Employee where salary < (select max(salary) from Employee)
@balaji27venkatesh25 күн бұрын
select firstName, lastName, city, state from Person as p left join Address as a on p.personId = a.personId
@balaji27venkatesh25 күн бұрын
select event_day as day, emp_id, sum(out_time - in_time) as total_time from Employees group by 1,2
@sachin-b8c4m27 күн бұрын
thank you please continue making videos
@sachin-b8c4m27 күн бұрын
thank you please continue making videos
@sachin-b8c4m27 күн бұрын
thank you
@sachin-b8c4m28 күн бұрын
this is very helpful, thanks for sharing
@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Ай бұрын
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Ай бұрын
I started out as a programmer myself! Great to hear you were able to take something away from the video.
@boredperson82Ай бұрын
why are we selecting event_date in subquery?
@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Ай бұрын
you videos are very helpful, kindly continue making videos .
@SomeRandomName9999992 ай бұрын
Why sum(b.weight) instead of (a.weight)?
@sachin-b8c4m2 ай бұрын
thanks
@sachin-b8c4m2 ай бұрын
thank you
@ANKITSINGH-fz3ft3 ай бұрын
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?
@frederikmuller3 ай бұрын
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.
@newtc933 ай бұрын
ure amazing
@frederikmuller3 ай бұрын
no u
@giannizifarelli30603 ай бұрын
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
@frederikmuller3 ай бұрын
Your query allows for sales in other years than 2019. Also it doesn’t account for the product ONLY selling in spring 2019.
@HelloIamLauraa3 ай бұрын
i didn't hear about this page yet
@frederikmuller3 ай бұрын
you should give it a try!
@HelloIamLauraa3 ай бұрын
@@frederikmuller are there also nlp, ML questions or more like db and sql interview question?
@aliebi134 ай бұрын
WOW This is an efficient code😍
@curiously-cinnamon4 ай бұрын
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
@sabisingh96354 ай бұрын
Why is it a sum and not count in your query? Aren’t we counting number of cancelled rides ??
@frederikmuller4 ай бұрын
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.
@Savenature6354 ай бұрын
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;