Have been doing SQL for years, but your clips are still very informative. Thanks.
@arihantdhadiwal91153 жыл бұрын
Amongst so many tutorials out there on youtube , hands down your's are the best. Will eagerly wait for your upcoming uploads . thanks
@techTFQ3 жыл бұрын
Thank you Arihant 🙏🏼 Am so glad to hear you liked my contents 🙂
@joe22712 жыл бұрын
Seriously. You are awesome and explain it so well
@techTFQ2 жыл бұрын
Thank you 🙏🏼
@minalgupta74562 жыл бұрын
I agree
@racheldong60 Жыл бұрын
this is a great presentation to explain how to pull N consecutive records! Thank you
@arindamnath12332 жыл бұрын
The best explanation for consecutive record fetching I ever get. Thank you
@techTFQ2 жыл бұрын
Glad you think so 🙏🏼
@guchhusworld587 Жыл бұрын
Thanks TFQ for your videos. Just wanted tweak the last part of the query to make it more generic. With t1 as ( select id,city,temperature,day, row_number() over (order by id) as diff, id - row_number() over (order by id) as conse from weather where temperature
@mananshah70952 жыл бұрын
You are one of the best SQL instructor on KZbin. I have been using SQL for more than 2 years but still I have learnt so much from you. Please keep uploading the videos. Thank you!
@techTFQ2 жыл бұрын
Glad to hear that Manah :)
@reigngamer942 жыл бұрын
Complex query explained in the best way
@techTFQ2 жыл бұрын
Thank you :)
@bhuwanthapliyal79773 жыл бұрын
No doubt your videos are more elaborate and better than institutes charging so much. One request, please create a series for SQL to cover end to end course
@techTFQ3 жыл бұрын
Thank you Bhuwan.. glad you like it 🙏🏼 Yes I will make detailed SQL tutorial videos in the near future..
@InvisibleDivide2 жыл бұрын
Solution is so simple yet so big brain at the same time.
@karthikd21043 жыл бұрын
Clear explanation ! Easy way to understand!
@techTFQ3 жыл бұрын
Thank you Karthik 🙏🏼 Glad you liked it ..
@ashabhumza33942 жыл бұрын
Mashallah! You are really an SQL genius... 👍
@techTFQ2 жыл бұрын
Thank you Ashab ☺️
@abhilashs31602 жыл бұрын
Great way of explaining complex concepts so that everyone can understand it clearly, you are a life saver.
@techTFQ2 жыл бұрын
Thank you Abhilash .. glad you liked it
@vikranttyagi52322 жыл бұрын
All of your SQL videos are really helpful to understand the advanced concepts. Thanks for making them.
@techTFQ2 жыл бұрын
Thank you Vikrant :)
@pavangsk8404 Жыл бұрын
you have touth a very important problem in awesome way... brillliant sir
@vikaskumar-qr5tj3 жыл бұрын
Beautiful explanation just crystal clear.....
@techTFQ3 жыл бұрын
Thank you vikas
@aashishmalhotra2 жыл бұрын
Perfect zoom for phone user , perfect mic , and perfect execution to approach a problem! Make more videos on companies SQL questions and your channel will definitely grow.
@techTFQ2 жыл бұрын
Thank you :)
@hungphutr3 жыл бұрын
thank you for the tutorial, super helpful!. for the last problem, I think we can increase the complexity by having multiple order records within a day. by that way, each orderID is no longer a unique indicator of a day for us to calculate the difference. I think there will be just one extra step that is to get to the current table structure like we have in this video by creating a new table grouped by order_date and generating a new id column using row_number.
@IMHitesh3 жыл бұрын
Thanks for solving this.... I was searching for the solution since so many days great effort... cheers
@techTFQ3 жыл бұрын
Your welcome Hitesh 🙏🏼 Glad this helped you..
@microvlog06 Жыл бұрын
your video helped me in solving leetcode hard problem. Thankyou!😀
@SagarKumar-db2xy3 жыл бұрын
Trust me, you are the best. Please post more videos on interview questions for beginners.
@techTFQ3 жыл бұрын
Thank you Sagar 🙏🏼 Very happy to know you like my content 🙂
@TheIndianSocial8 ай бұрын
best explanation for the streak concept.
@sajidsshaikh7072 жыл бұрын
Yes, indeed your tutorials are really helpful man !!
@techTFQ2 жыл бұрын
Glad to hear that sajid!
@KrishnaYadav-ge5re2 жыл бұрын
I am very happy and excited to see more videos from you.. YOUR VIDEOS ARE AWESOME.. Great explainations
@tsukuruuu Жыл бұрын
midway on the video , i immediately clicked on subscribe. this is a gem!
@techTFQ11 ай бұрын
Thank you
@girijashamak91423 жыл бұрын
One more gem of a content
@techTFQ3 жыл бұрын
Thank you Girija for such kind words 🙏🏼🙏🏼
@askarhameedka29533 жыл бұрын
I cleared one assessment with this code. thanks
@techTFQ3 жыл бұрын
That’s great to hear 😃 Congratulations 👏
@salmanbaig152 жыл бұрын
Terrific explanation.. Thank you!
@siribn26572 жыл бұрын
Super helpful tutorial, brilliantly explained. waiting for more of these kinds..
@techTFQ2 жыл бұрын
Thank you Siri 🙏🏼
@benoitpatigny3 жыл бұрын
Thank you for your awesome explanation, it's very useful, have a consecutive nice day
@techTFQ3 жыл бұрын
😃 Thank you Benoit 🙏🏼 Glad this helped ..
@nileshkadivar62812 жыл бұрын
Very well explained about problem statement. Watched many videos regarding SQL on your channel and it's easy to understand. 👏👌
@techTFQ2 жыл бұрын
Thank you Nilesh
@GreatNishan3 жыл бұрын
Nice video. I wish you post a continuation of this video by using “Preceding 1 and following 1” window clause and solving these questions.
@techTFQ3 жыл бұрын
Thank you Nishan 🙏🏼 Glad you liked this video.. As for your suggestion, let me consider this and may be plan for a future video..
@tinurathi52102 жыл бұрын
Thank you.. this is very helpful!
@sivagssri3 жыл бұрын
Wat to go... Such a crisp n clear explanation even for experience guy like me, got to see your channel and recommend to my group.
@techTFQ3 жыл бұрын
Thank you Siva 🙏🏼 Happy to know you found some value from this video 🙂
@sonalivv3 жыл бұрын
This was brilliant! A perfect blend of math and SQL. Keep these videos coming!
@techTFQ3 жыл бұрын
Thank you so much 🙏🏼 So glad you find this useful 🙂
@swatisinha32303 жыл бұрын
Very helpful. I used to struggle with this, but this explanation is worth watching :)
@techTFQ3 жыл бұрын
Thank you Swati 🙏🏼 Glad this helped ..
@reddaiahreddymallu Жыл бұрын
Thank you, Thoufiq.
@fathimafarahna26333 жыл бұрын
Amazing clarity and explanation👌 Keep up spreading knowledge. God bless 🙏
@techTFQ3 жыл бұрын
Thank you ❤️
@bibekrawat22842 жыл бұрын
Such a nice concept.
@techTFQ2 жыл бұрын
Thank you 🙏🏼
@flwi2 жыл бұрын
That is a very clever approach imho! Well done!
@purnamohan299111 ай бұрын
very helpful sir, thanks a lot.
@KSudS_3 жыл бұрын
Great job. Pls we need to tackle more sql queries. If you can handle 10 questions per video, will be awesome. thanks.
@techTFQ3 жыл бұрын
Thank you 🙏🏼 Sure will plan it out..
@piyushpathak73113 жыл бұрын
Sir we want more videos like this.. PLZZ upload..
@techTFQ3 жыл бұрын
Thank you for liking my content Piyush 🙏🏼 Will try my best to upload more such contents 🙏🏼☺️
@shoboyjr2 жыл бұрын
This is really helpful! Thank you!
@karthikeyan_thangavel3 жыл бұрын
Very well helped at very critical situation... 🤗🥳🎊
@techTFQ3 жыл бұрын
Nice to know that .. glad this helped 😃
@zaraahmed15972 жыл бұрын
Loved the approach.Thanks for sharing :)
@techTFQ2 жыл бұрын
Your welcome 🙏🏼 Glad this helped
@TheRaju9912 жыл бұрын
This was super helpful 👍
@MehmetEratli Жыл бұрын
Thank you so much for the amazing content! Are you planning to do more videos like this or where you solve stratascratch problems? Those would also be super helpful to see how you approach problems
@srt58063 жыл бұрын
Crisply explained!
@techTFQ3 жыл бұрын
Thank you 🙏🏼
@hadireg2 жыл бұрын
Thanks mate! Very useful indeed
@techTFQ2 жыл бұрын
Your welcome buddy
@shivsharma91533 жыл бұрын
REALLY ENJOYING CHANNEL!!
@techTFQ3 жыл бұрын
Thank you Shiv 🙏🏼 Glad you like the channel 🙂
@aneksingh44963 жыл бұрын
Really good and nicely explained
@techTFQ3 жыл бұрын
Thank you Anek 🙏🏼
@flaviusioan693 жыл бұрын
Great tutorial ... Thnx
@techTFQ3 жыл бұрын
Thank you Frisan 🙏
@prachijain59603 жыл бұрын
Informative video. Please share some videos on outliers
@techTFQ3 жыл бұрын
Thanks Prachi 🙏🏼 Let me consider your suggestion for a future video ..
@juhairahamed53422 жыл бұрын
Good explanation
@techTFQ2 жыл бұрын
Thank you :)
@mohammedshahil48983 жыл бұрын
Really very helpful🙌🏻👌🏻 Thank you for this yet another amazing video✌️
@techTFQ3 жыл бұрын
Thank you hero 🙏🏼 I am glad to know you benefit from these videos 🙂😍
@hanweithoo50083 жыл бұрын
Tabibitosan method. Great stuff !
@techTFQ3 жыл бұрын
Thank you HanWei 🙏🏼 Glad you liked it ..
@ShivamTiwari-on2kl Жыл бұрын
I had a different approach using lead/lag window functions. So I will basically check if the lead/lag values are same as the current row values (both +ve or -ve) and if they are, i will assign them same ids using case statement
@sachinpatel-oq3ib3 жыл бұрын
learned something new 👍
@techTFQ3 жыл бұрын
Thank you Sachin 🙏🏼 So glad I was able to teach you something new 🙂
@shafiquek99603 жыл бұрын
Well explained.
@techTFQ3 жыл бұрын
Thank you Shafique 🙏🏼 So glad you are liking my video 🙂
@santhoshkumarj46483 жыл бұрын
Genius 🔥🔥 pls post more videos
@techTFQ3 жыл бұрын
Thank you Santhosh and will do 🙏🏼
@sheebaparveen36303 жыл бұрын
Great . Such good videos 🔥🔥💯💯💯
@techTFQ3 жыл бұрын
Thank you cheeb ❤️
@SudhirKumar-rl4wt2 жыл бұрын
Thanks for the tutorial ..in the last solution ..I think it's the order_date column that establishes the fact that two rows are consecutive because order_id is varchar and comparing one order_id with another order_id doesn't make a lot of sense..so row_number() should be over order_date and not over order_id.because our final ouput should say which orders(order_id) are consecutive..we shouldn't make that assumption.
@SudhirKumar-rl4wt2 жыл бұрын
Here Order_date should substitute ID(primary key) from first problem/solution
@shahinurrahman77452 жыл бұрын
Awesome explanation! Just one query- instead of partition we can use group by - having clause also, right? Any particular reason to use partitioning? Thanks again for all of your wonderful videos!
@techTFQ2 жыл бұрын
Thank you 🙏🏼 Group by and partition by in window function are 2 completely different concepts.. this query is best solved using partition by .. Explaining the difference between these 2, cannot be done in comment but may need a separate video for it ..
@nawalambavkar75433 жыл бұрын
Hi Thank you amazing videos Learnt a lot from you Can you please suggest some websites for practising SQL queries for data science
@techTFQ3 жыл бұрын
Thank you 🙏🏼 Not really sure if there is any website for SQL practice focused on data science but I would recommend using leetcode to practice SQL queries.. I’ve made a separate video about leetcode and how to find SQL questions on it. You can check that out on my channel
@divya0010072 ай бұрын
Thank you so much for your best tutorials @thoufiq_sir , it was really an amazing explanation. Tqsm for ur efforts
@anudeepreddy555910 ай бұрын
Superb Thoufiq ❤❤
@sandeepkumar-ol5lg2 жыл бұрын
Amazing explanation, by the way you’re using a tool or any online editor to run queries .
@techTFQ2 жыл бұрын
Thank you :) I use PostgreSQL database and PgAdmin tool to write queries
@bhavaniethirajan96273 жыл бұрын
Hi.. first of all your way of explanation is awesome and easy understanding thanku for that.. one thing only couldn't understand like in ur example for pk ID u have given values as 1,2,3....n and row number will be 1,2,3....n so u can filter temperature less than zero n did subtraction between pk id and row number but what if pk id values will be starting like 2456,2457 n so on? How can we group this kinda values
@techTFQ3 жыл бұрын
Thank you for the kind feedback Bhavani 🙏🏼 Even if ID is any other numeric value (as long as it is unique) , the logic would work fine.. In case the ID is non numeric then you can explicitly create an ID column (using row number) as I mentioned in one of the examples..
@ameygoesgaming87937 ай бұрын
gold content
@munna14310002 жыл бұрын
@techTFQ Is there a way to get dump of data or database which you walkthrough in your videos ?
@techTFQ2 жыл бұрын
Yes you can find it in my blog and I have provided the link to my blog in the video description
@sudhindrab1606 Жыл бұрын
alternate solution for the last problem: select * from (select * , count(*) over(partition by substring(order_date,0,8)) as no_of_records from orders)s where no_of_records =1
@AraSh-yn2tt3 жыл бұрын
That was nice bro, helped a lot, please keep going. Btw, could you post a video about how to calculate l, for example, growth rate in one specific column through time? In general, how to perform mathematical operations on grouped columns
@techTFQ3 жыл бұрын
Thank you for the suggestion Ara.. Ill consider this for a future video..
@belikk19862 жыл бұрын
Great tutorial! What if i have multiple records per one day and i still need to count quantity of consequtive days?
@vishalsvits2 жыл бұрын
Hi , at 17:16 . over clause must have order by.
@MrManda0072 жыл бұрын
In the first case when you have an id and then do subtraction it can be done only in this dataset there is no math rule who will guarantee that subtraction id from the generated column will give you the numbers you get in your example. For example in my case id column is the same as generated column and the different field is always zero. 1- 1 =0 2-2=0 etc. You just find the way who will work on this dataset.
@sumitkumar-zv4xb Жыл бұрын
HEY TFQ, A little tweak in this problem how i can find the maximum consecutive days for which the temperature was less than 0.
@quantum6343 жыл бұрын
Hei it's me once again, just saw you answer to my comment in your previous Video and I was hei that's so cool from him..1 second later I see, you already uploaded the video haha :) Thank you for making an extra tutorial explaing this ! Very well done ! My question is answered completely. Keep up the good work. :)
@techTFQ3 жыл бұрын
Hey … thank you so much 🙏🏼 I am so glad this video was able to answer your previous question 🙂 And thank you again for the feedback and for the appreciation 🙏🏼☺️
@mohammadshahbaz32879 ай бұрын
@techTFQ one question - for the case #2 scenario - without primary key, if u assign row_number with any order by clause, then its possible u would end up getting random ordering & might get wrong result, right?
@pveeranjireddy89593 жыл бұрын
Great videos bro ... I subscribed channel...
@techTFQ3 жыл бұрын
Thank you 🙏🏼 So glad you liked the content 🙂
@harshitsinha46335 ай бұрын
21:28 in 3rd part, row number is itself an int how you converting if, (date- int )how it is working in date, we use datediff funct for difference
@databasewala63842 жыл бұрын
Can you please make a video to delete duplicate records without using rowid.
@nandhinisekar96893 жыл бұрын
Awesome
@techTFQ3 жыл бұрын
Thank you 🙏🏼 Glad you liked it 🙂
@jasdeepsinghmonga43832 жыл бұрын
How to find the difference in MySQL for last problem? Not able to do it using Cast
@priyanshu.tiwari2 жыл бұрын
For Second Part, In MSSQL, this can be used: WITH T1 AS ( select *, ROW_NUMBER() OVER (ORDER BY order_id) AS RowNumber, DATEADD(day,-ROW_NUMBER() OVER (ORDER BY order_id),order_date) AS DIFF FROM orders ), T2 AS ( SELECT *,count(*) over(partition by DIFF) as no_of_records FROM T1 ) SELECT * FROM T2 WHERE no_of_records=3; Thank you :)
@akhilkishore73612 жыл бұрын
what if there are multiple cities and you need to get the temp group by each city
@praneethmuragani Жыл бұрын
Hi bro! here is my solution select id, city, temperature, day from ( select *, lag(temperature) over(order by day asc) as lg, lead(temperature) over(order by day asc) as ld from weather ) tbl where temperature < 0 and (lg < 0 or ld < 0) and (lg is not null or ld is not null)
@vishalrana95942 жыл бұрын
A very informative video....just have a small doubt in the second part in which we don't have a primary key and we are assigning row numbers twice...In the first part, we had primary key that was different to row number but in the second case, both sets will be the same... So id-Row_num will give output as 0 for all...Please correct me if I am wrong.
@gparvez66952 жыл бұрын
Hello, I am working in mysql work bench. I cam up with an issue that when I use cast function to convert the rownumber to int i.e (date - cast(row_number() over()) as int ) as diff. Could you please help me solve with this issue.
@Thesussyboi412 Жыл бұрын
Given the users purchase history write a query to print users who have done purchase on more than 1 day and products purchased on a given day are never repeated on any other day. Here is the ready script: create table purchase_history (userid int ,productid int ,purchasedate date ); SET DATEFORMAT dmy; insert into purchase_history values (1,1,'23-01-2012') ,(1,2,'23-01-2012') ,(1,3,'25-01-2012') ,(2,1,'23-01-2012') ,(2,2,'23-01-2012') ,(2,2,'25-01-2012') ,(2,4,'25-01-2012') ,(3,4,'23-01-2012') ,(3,1,'23-01-2012') ,(4,1,'23-01-2012') ,(4,2,'25-01-2012'); Can you provide the answer for above query?
@jackdesparrow4783 Жыл бұрын
I have a doubt in 1st query. When there is 2 consecutive I'ds having t
@kasturipal55222 жыл бұрын
Hi , I have been seriously following your blog , but the solution is not working for me when solving leetcode 180 prob .With t1 as (select * , row_number() over(order by id) as rn, id - (row_number() over(order by id)) as difference from Logs ) , t2 as (select *, count(*) over(partition by difference) as no_of_records from t1) select num as ConsecutiveNums from t2 where no_of_records >= 3; Can you please check
@sql87582 жыл бұрын
Hi Thank you very much for the video. it's super helpful. I have one question, instead of create a new temporary table t2, can we just use t1 and GROUP BY? For example in the last example, after creating t1, I will just write: 'SELECT * FROM t1 GROUP BY no_of_records HAVING COUNT(*)=3' Does this work?
@guchhusworld587 Жыл бұрын
select * with a group by wont work
@arnabdas4056 Жыл бұрын
How can the logic work I didn't get it consider a date 2022-01-04 and I'd value 4 and temp say -1and I have to determine 4 consecutive days.it will break the entire logic.
@shr_ee._________ Жыл бұрын
sir , how to find out customers who did orders in consecutive months ? when customer_id , order_id and order_date is given ?? please reply me .. i really need help ..
@MrRajat769 Жыл бұрын
How to find last 12 months sales from last visit date
@unknown-ph4yb2 жыл бұрын
I have a query can u explain this please
@techTFQ2 жыл бұрын
Sorry but I cannot assist anyone personally due to my time constraints
@akhilgupta5133 жыл бұрын
For the solutions where you are relying on PK (ID/OrderId) to be in asc order to do the maths. Let's say PK (ID /Order ID) is not already sorted? (Except VW , where date is not given)
@阿哲玩家3 жыл бұрын
you can create another row_number in asc number as temp column and use it to do the remaining maths.
@hajarigupta121Ай бұрын
hello sir , i m recently started my MYSQL learning and following your learning but some where i get confuse regarding the query for cast the text in integer as it showing error and i m trying to do the same with CTE clause and join but i m not getting proper solution , so please guide me sir. question is : -- Finding n consecutive records with consecutive date value. i have try by this : create table dates( order_id varchar(20) primary key, order_date date); insert into dates values ('ORD1001', '2021-01-01'), ('ORD1002', '2021-02-01'), ('ORD1003', '2021-03-02'), ('ORD1004', '2021-02-03'), ('ORD1005', '2021-03-01'), ('ORD1006', '2021-06-01'), ('ORD1007', '2021-12-25'), ('ORD1008', '2021-12-26'); select * from dates; with Table1 as( select *,row_number()over(order by order_date)as id from dates ), demo as (select T1.order_id,T1.order_date from Table1 T1 join Table1 T2 on T1.id = T2.id+1 and T1.order_date =T2. order_date +interval 1 day ) select * from demo ; your solution : with t1 as (select *, row_number() over(order by order_date) as rn, order_date - cast(row_number() over(order by order_date)::numeric as int) as diff from dates), t2 as (select *, count(1) over (partition by diff) as cnt from t1) select order_id, order_date from t2 where cnt >= 3;
@asifrehman88373 жыл бұрын
What if after 6th primary key number, again there is another 3 consecutive records?
@techTFQ3 жыл бұрын
this query would capture any no of consecutive records.. Let me know if you have a example where this would not work..
@snehalsanap17502 жыл бұрын
hi, while doing this 3rd part where only date is given both in mysql and ssms the cast operation over id and subtraction of it with date is giving error... operand type
@snehalsanap17502 жыл бұрын
select *, row_number() over(order by order_id) as rn, order_date - cast(row_number() over(order by order_id) as int) as difference from orders; error Operand type clash: date is incompatible with int - both in msql workbench and ssms.. how to solve? @ techTFQ