Top 10 SQL Interview Queries | Popular SQL Queries for SQL Interview

  Рет қаралды 197,354

techTFQ

techTFQ

Күн бұрын

In this video, we look at 10 commonly asked SQL Queries during interviews. These are in my opinion top 10 SQL queries to learn before going to any SQL Interview. These 10 queries will cover most of the important SQL concepts hence if you can solve these 10 queries then you would have a very good understanding of SQL.
Download all 10 SQL query scripts, solutions, and problem statements from my blog below:
techtfq.com/blog/top-10-sql-i...
Check out one of the BEST platforms to learn SQL:
learnsql.com/?ref=thoufiqmoha...
Get yourself a "Certificate of Competency in SQL" for free from below:
learnsql.com/sql-skill-assess...
Timestamp:
00:00 Intro
01:03 Query 1
04:25 Query 2
07:34 LearnSQL
09:34 Get your Free SQL Competence Certificate
10:14 Query 3
12:59 Query 4
16:05 Query 5
19:56 Query 6
23:27 Query 7
26:03 Query 8
27:58 Query 9
31:13 Query 10
More Videos:
Delete Duplicate data (10 ways):
• How to remove Duplicat...
Window function Frame clause Tutorial:
• SQL Window Function | ...
JOINS Tutorial (SELF Join)
• SQL JOINS Tutorial for...
Recursive SQL Tutorial:
• Recursive SQL Queries ...
Subqueries Tutorial:
• Subquery in SQL | Corr...
Thanks for watching!
Thoufiq | techTFQ

Пікірлер: 193
@techTFQ
@techTFQ 6 ай бұрын
Check out the learn SQL platform here: learnsql.com/?ref=thoufiqmohammed Get yourself a "Certificate of Competency in SQL" for free from below: learnsql.com/sql-skill-assessment
@Dreamtitan
@Dreamtitan 6 ай бұрын
Amazing content Thanks man
@Malathi_Steps
@Malathi_Steps 6 ай бұрын
Thank you sooo much Toufiq for this SQL course! Thanks a lot! 🙏
@techTFQ
@techTFQ 6 ай бұрын
Your welcome bro
@Malathi_Steps
@Malathi_Steps 6 ай бұрын
Hi Toufiq! I have gone through SQL course from the beginning to brush up my skills and all the concepts. In the recent interview, I cleared all the technical rounds and I got placed last week with a good hike. Your videos and your teaching helped me a lot.! I am really Happy! Please keep going. God bless you!
@techTFQ
@techTFQ 6 ай бұрын
Congragulations Malathi.. very happy for you. Super glad to know my content helped :)
@Malathi_Steps
@Malathi_Steps 6 ай бұрын
Thank you soo much! @@techTFQ
@sesharoxz5311
@sesharoxz5311 6 ай бұрын
Can you please share the course videos
@richakapoor445
@richakapoor445 6 ай бұрын
@@Malathi_Steps hi , could you please some SQL interview questions which was asked in your interview?, as my interview is tomorrow
@Malathi_Steps
@Malathi_Steps 6 ай бұрын
@@richakapoor445 - Sure. There are mainly these concepts were asked: 1. Finding Duplicates, deleting the duplicates(not all the records, 1 should be there), 2. all types of joins, especially the self join 3. Differences b/w delete, drop, truncate 4. Rank(),Dense Rank(), Row num 5. last 10 records, first 10 records 6. highest salary, lowest salary of an employee in each dept 7. set operators and the difference b/w union and union all 8. data base related questions like: how to test if source DB and Target DB are different 9. questions on like operators ex: name starts with letter 'M' and ends with 'N' etc. 10. all null functions. case statement etc. For me, they asked about API testing as well(their requirement). Hope this helps! All the best!
@vijayreddy5328
@vijayreddy5328 5 ай бұрын
Thank you Toufiq, for question 4 we can do in very simple way instead writing such complex query select least(startingpoint,endingpoint),greatest(startingpoint,endingpoint),distance from distance;
@ezhankhan1035
@ezhankhan1035 4 ай бұрын
Your Channel is one the best when it comes to taking SQL to the next level. Really appreciate this content, thank you!
@debapriyabehera7146
@debapriyabehera7146 2 ай бұрын
After watching your SQL videos I thought my thinking capability increase gradually that where to think about to write a query....😊 Thanks a lot.....
@tmstechschool7239
@tmstechschool7239 5 ай бұрын
Dear Toufiq, I would say thank you for your effort. On Question 5 I didn't get the point of joining with the original table, I think it could work as expected with out joining the cte with the original table as follow unless we have some edge condition we should consider. with recursive cte as ( select id, item_name, total_count, 1 as level from travel_items union all select cte.id, cte.item_name, cte.total_count -1, level + 1 as level from cte where cte.total_count > 1 ) select id, item_name, level from cte
@RohitSaini52945
@RohitSaini52945 4 ай бұрын
with recursive cte as ( select id, item_name, total_count, 1 as lvl from travel_items union select id, item_name,total_count, lvl+1 as lvl from cte where lvl
@malcorub
@malcorub 3 ай бұрын
Awesome video!!! I'm using SQL server. What I do to follow along is CREATE TABLE and INSERT INTO the same simple tables/data and try to solve it before watching your solutions. Some we did exactly the same.... others we went about it a different way. Either way, this is a fantastic video to prep you for SQL Interviews. Thank you!!!!
@inbox.sanatan
@inbox.sanatan 6 ай бұрын
Haven't seen any channel creating this gold level across platform
@techTFQ
@techTFQ 5 ай бұрын
Thank you:)
@tonysun203
@tonysun203 6 ай бұрын
Hi Toufiq. Thanks a lot for providing so many useful examples on solving SQL. I have been learning quite a lot from your videos and your SQL / python courses. Really appreciate for these courses and videos that you have done for us. Also, thanks for introducing the learnSQL website to us. I have registered for the life time eLearning also. Also, you are the best teacher I've met on learning SQL. Hope you continue to make these quality and useful video for us. Keep going brother 👍 From Tony
@techTFQ
@techTFQ 5 ай бұрын
Thank you Tony. Glad it helped :)
@sujaa1000
@sujaa1000 5 ай бұрын
Thank you very much TFQ, this was so helpful!
@neha_7gupta846
@neha_7gupta846 3 ай бұрын
Thankyou , Its helpful and correct question which are asked in Interviews
@mmmuneer707
@mmmuneer707 6 ай бұрын
Hi Toufiq!! All question are so interesting. I just found few things which effects the query. Q1) The table has only 2 duplicate rows, assume if table has 3 duplicate rows then sol 1 and sol 2 won't work as it will select MAX() and MIN() model_id. Here most accurate sol is sol 3 using ROW_NUMBER(). Q7) In this to write negative amount as (amount$), || won't work in MYSQL instead CONCAT() can be used.
@ramshataqdees5570
@ramshataqdees5570 6 ай бұрын
partition by which column?
@ramshataqdees5570
@ramshataqdees5570 6 ай бұрын
how can i call dataset in first query as having duplicates ?since there is a primary key id
@umangbhatnagar1415
@umangbhatnagar1415 3 ай бұрын
what the hell are you saying ?? It will work, analyse sol1 and sol2 and then think. Just don't mug up !!
@ryuhayabusa3540
@ryuhayabusa3540 3 ай бұрын
|| also knowns as pipes does work in mysql. You just have to turn it on by doing this: SET SQL_MODE = 'PIPES_AS_CONCAT';
@juno7893
@juno7893 3 ай бұрын
Very informative. Thank you🙏
@Batira583
@Batira583 6 ай бұрын
Always a pleasure to watch your videos Thofik. I m learning a lot from you .
@techTFQ
@techTFQ 6 ай бұрын
Thanks a lot bro. Truly appreciate it
@user-so8fh2hi9f
@user-so8fh2hi9f 15 күн бұрын
Great video! However, I think it is for more advanced SQL learners. Although i am an intermediate learner, it was very difficult to understand the concepts. But I keep learning..
@chandreshslal9686
@chandreshslal9686 4 ай бұрын
you are doing so awesome job
@user-vi2fp6dl7b
@user-vi2fp6dl7b Ай бұрын
Good job! Thank you very much!
@aleh3627
@aleh3627 6 ай бұрын
Can you make a video explaining how the joins on different row number ids or less than row numbers id work? I can't fully understand it. Thank you for all the great info!
@shekhark1139
@shekhark1139 6 ай бұрын
Please make a video about data execution in sql server, how to identify bad or good ( efficient or inefficient queries) , how the cost of query in percent matters
@mohammadshahbaz3287
@mohammadshahbaz3287 4 ай бұрын
@techTFQ an easier solve for the issue with min function is this - select *, min(salary) over(partition by dept order by salary) as min_sal , max(salary) over(partition by dept order by salary desc) as max_sal from table; This will ensure the frame issue wont come into picture, right?
@user-xe9zi9yw2e
@user-xe9zi9yw2e 6 ай бұрын
Hi, I've been working as a programmer for about two years in a financial company. However, I still struggle with understanding complex queries. While I get the few chance to write queries at work, there are instances where I need to read long queries, sometimes exceeding 500 sentences, due to unexpected circumstances. I genuinely make an effort to read and comprehend them, but when multiple challenging grammar concepts like outer joins and subqueries are used together, I find it difficult to grasp. In this situation, what should I focus on learning to improve my ability to read complex and lengthy query sentences? I really want to enhance my skills in this area.
@mohamedaaasimoo5209
@mohamedaaasimoo5209 2 ай бұрын
Top 👍
@mohdshajar247
@mohdshajar247 5 ай бұрын
Hi Taufiq, I just solved the problem no . 5 without join. Let's have a look and lemme know if i am correct. with recursive cte as ( select id, item_name, total_count, 1 as level from item union all select cte.id, cte.item_name, total_count - 1, level+1 as level from cte where total_count > 1 ) select cte.id, cte.item_name,level as cnt from cte order by id asc
@bugstophere
@bugstophere 5 ай бұрын
Nice explanation and it is very useful 👌👌
@mohammedshahil4898
@mohammedshahil4898 6 ай бұрын
Another quality content from Techtfq👌👌👏 Keep going brother🙌
@techTFQ
@techTFQ 5 ай бұрын
Thanks:)
@jyothikamatham98
@jyothikamatham98 5 ай бұрын
Thanks a lot
@muralibaddela9201
@muralibaddela9201 6 ай бұрын
Excellent questions Toufiq , covers quite a bit of SQL innards
@techTFQ
@techTFQ 5 ай бұрын
Thanks:)
@leeellllee
@leeellllee 4 ай бұрын
thank you for this video! would you say this level of SQL knowledge is generally tested for data engineer/data scientist roles as opposed to business functions? for example at a company like google or meta. thank you!
@ArunKumar-bp5lo
@ArunKumar-bp5lo 6 ай бұрын
the perfect video i never know i needed
@techTFQ
@techTFQ 5 ай бұрын
Thank you:)
@kusumsharma7293
@kusumsharma7293 4 ай бұрын
Hi Toufiq! I have been following all your videos regarding sql but this is can you make more videos, on my sql work bench and interview questions also
@ramjigupta174
@ramjigupta174 6 ай бұрын
Hi @techTFQ! In problem 10, Why are we not considering a case where order status is submitted and created for same user (3rd statement in the union)??
@aumprakashdehury
@aumprakashdehury 6 ай бұрын
Thank you Thoufiq, Really leaned a lot from you.
@techTFQ
@techTFQ 5 ай бұрын
Glad to hear that
@sevsxes
@sevsxes 6 ай бұрын
Thank you very much for such detailed info
@techTFQ
@techTFQ 5 ай бұрын
Welcome:)
@v75tan
@v75tan 5 ай бұрын
Great Work How I can select all the row specific column data in one column separate by ,. Like in a table userdetails has a column fullname. On 'select fullname from userdetails' I should not get rows. I should get single column (string) where values are separate by , Like: Ram Sing, Shayam, Sita Jha, Gita Migan
@crownaradhya
@crownaradhya 6 ай бұрын
Thank you , bahut sikhne ko milta he , aur questions late raho 👌👍
@techTFQ
@techTFQ 5 ай бұрын
Welcome
@nitinmehta9738
@nitinmehta9738 Ай бұрын
Excellent Thoufiq, thanks. Where can i find these queries for practice ?
@m.s.k5300
@m.s.k5300 6 ай бұрын
Nice thofiq
@techTFQ
@techTFQ 6 ай бұрын
thanks buddy
@WelcomeToMyLife888
@WelcomeToMyLife888 6 ай бұрын
Awesome content as usual!
@techTFQ
@techTFQ 5 ай бұрын
Appreciate it!
@sudarshansbhat8665
@sudarshansbhat8665 6 ай бұрын
Hi techtfq, can you please elaborate how the join works internally when 2 or more tables are joined. I am getting confused often when I try to join the third table. Please help me in this with clear picture how the intermediate tables are created and within this already joined two tables are joined with third table. So after joining the first two tables when I write a condition to join third table from which table I should pick the column to join condition.
@premanandramasamy
@premanandramasamy 20 күн бұрын
Hi @Toufiq, Greeting for the day champ!! One doubt at problem#4. In case if only one source and destination is there in original table, expected output will not return that unique one right?
@rahulshahapure2298
@rahulshahapure2298 5 ай бұрын
Superb !!.. Your content really helps with approach that could be taken. 🙂👍
@techTFQ
@techTFQ 5 ай бұрын
Glad to hear that
@srinubathina7191
@srinubathina7191 6 ай бұрын
Thank you Amazing content
@techTFQ
@techTFQ 5 ай бұрын
Glad you enjoy it!
@umangbhatnagar1415
@umangbhatnagar1415 6 ай бұрын
Really Really Awesome !!
@techTFQ
@techTFQ 6 ай бұрын
Thanks a lot!
@Aparna.Ratheesh
@Aparna.Ratheesh 6 ай бұрын
Hi TFQ, Thanks for these free tutorials. Please do share a collection of medium and tricky SQL queries and solutions so we can practice before an interview.
@techTFQ
@techTFQ 5 ай бұрын
kzfaq.info/get/bejne/l6tmZZaXy53em4E.html&pp=gAQBiAQB
@mohammadshahbaz3287
@mohammadshahbaz3287 4 ай бұрын
Hi Toufiq, for Quest #6, part 2 each team plays every other team twice, a much simpler solution would be to do Union ALL of part 1 I.e. every team plays other team once *2 i.e. union ALL of this , right? Let me know if there's some flaw in my thinking?
@jalajareddy6397
@jalajareddy6397 2 ай бұрын
select max(salary) , min(salary) , dept from employee group by dept ..... i think this is a better solution for query 2 ......please let me know if any mistake from my end
@Uzzis-Life
@Uzzis-Life Ай бұрын
Hi Taufiq, I had been asked to write sql query to names in alternate rows, say for example a table have "name" colum having 10 rows, data as "abc" 5 rows and "xyz" 5 rows, and I need to display these "abc" and "xyz" in alternate rows as abc xyz abc xyz so on
@shivinmehta7368
@shivinmehta7368 5 ай бұрын
i think query 2 output is wrong for IT department as we have to find highest and lowest salary for each department and the query you mentioned is showing other salaries as well my solution for q2 select * from ( select *, max(salary) over(partition by dept rows between unbounded preceding and unbounded following) as "highest_sal", min(salary) over(partition by dept rows between unbounded preceding and unbounded following) as "lowest_sal" from employee order by dept,salary desc)x where salary in(highest_sal,lowest_sal);
@shruthigowda5985
@shruthigowda5985 6 ай бұрын
Pls make query tuning videos..
@vinaygc1284
@vinaygc1284 2 ай бұрын
thanks fir video Do yiu have videos for plsql
@bhavini9589
@bhavini9589 3 ай бұрын
Can you please provide vedio for performance tuning or SP optimization
@MaddyIndia
@MaddyIndia 6 күн бұрын
For #1 , solution #1 group by on name, color and brand.
@saivaibhav3331
@saivaibhav3331 6 ай бұрын
For question 4 we can do like this also with cte as ( select *, row_number() over(order by (select null)) as rn from src_dest_distance) select source,destination,distance from cte where rn%20
@sunidhas
@sunidhas 6 ай бұрын
The solution in the video for question 4 doesn't work if there is only one entry like mumbai to kerala. but this solution works on that criteria.
@zizu7755
@zizu7755 2 ай бұрын
Absolutely better solution. This query covers all scenarios and also in SQL Server you are not able to write ROW_NUMBER without ORDER BY clause, what he did in his video.
@zuko655
@zuko655 4 ай бұрын
Small improvement for Query 2 Solution: As per MySQL 8.0 Docs, the frame_clause defaults to RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING when ORDER BY is not present. And the order of the partitioned rows does not matter for the purpose of the query. Therefore you can remove the ORDER BY clauses for both partitions: SELECT *, MAX(salary) OVER(PARTITION BY dept) AS highest_salary, MIN(salary) OVER(PARTITION BY dept) AS lowest_salary FROM employee;
@fathimafarahna2633
@fathimafarahna2633 6 ай бұрын
Always a privilege for learners to get your video … You are doing a good service 👌God bless your efforts
@techTFQ
@techTFQ 5 ай бұрын
Thank you:)
@DataAnalyst251
@DataAnalyst251 6 ай бұрын
​Hi taufiq! Can you make logical interview questions more?
@techTFQ
@techTFQ 6 ай бұрын
Can you clarify what you mean by logical questions?
@DataAnalyst251
@DataAnalyst251 6 ай бұрын
I have reviewed your top 25 SQL questions on the blog and also watched the video on Joins for interviews. The interviewer has been posing more questions of this nature, particularly those based on scenarios.@@techTFQ
@da_vinci5100
@da_vinci5100 6 ай бұрын
Hey Toufeeq! I have been trying buy your SQL recording from your website but it doesn't allow me to move forward from cart. Can you fix this?
@ManojKumar-rm6io
@ManojKumar-rm6io 27 күн бұрын
Thanks for such good explanation on these problems. I have a question about query5, why do we need join in the recursive part. Will it not work woithout join. e.g. below query worked for me. WITH RECURSIVE trvl_itm AS ( SELECT id, item_name, count_of, 1 AS level FROM travel_items UNION ALL SELECT id, item_name, trvl_itm.count_of-1, LEVEL+ 1 AS level FROM trvl_itm WHERE trvl_itm.count_of > 1 ) SELECT id, item_name, level FROM trvl_itm ORDER BY id, level;
@moviebuff3030
@moviebuff3030 2 ай бұрын
For query 5, why there's need of join first base table will work and input for the 2nd query. then why need of join in query 5. i got solution without join in MS SQL with cte as (select id, item_name, total_count from travel_items union all select id, item_name, total_count - 1 as total_count from cte where total_count > 1 ) select * from cte
@maghy_kethychannel
@maghy_kethychannel 6 ай бұрын
hi toufiq plz do more videos on data analytics and how to do more analytical work with excel.plz plz
@techTFQ
@techTFQ 5 ай бұрын
Noted
@AbhijitMorye
@AbhijitMorye 2 ай бұрын
Hi Sir, for question number 5, I tried with different solution but with same recursive technique, solution --> with recursive cte as ( select id, item, count from travel_items union select id, item, count - 1 as count from cte where count > 1 )select id, item from cte order by id I tried this on mysql, and got expected output, is this correct?
@EditFolio
@EditFolio 4 ай бұрын
I have a doubt in the 1 query 1 solution what if the color is different but as per your code it will delete that record also right?
@pratik112ful
@pratik112ful 4 ай бұрын
Can I expect this kind of sql questions or more challenging than these with 2 years of DE experience?
@babhijit
@babhijit Ай бұрын
These types of sql questions are asked for data engineer/ data analyst roles only or for SDE roles also ?
@guneyfatma
@guneyfatma 3 ай бұрын
in query 2, is it not possible to use group and getting min and max of the salaries? It seems easier, I could not get why you used partition.
@pingdingdongpong
@pingdingdongpong 4 ай бұрын
For Q4, why can't you just do where source < destination? or swap and distinct.
@sowjyintivanta
@sowjyintivanta 5 ай бұрын
Hi,can u please tell me the difference between database, data warehouse, data lake and data mart . Please 🙏
@user-lh3dy8jo3d
@user-lh3dy8jo3d 6 ай бұрын
In the car duplicate question, you haven't mention color but if the color is different then it won't be a duplicate one right..then is it right to delete the record without considering color? Please clarify
@user-or4uw1uv1e
@user-or4uw1uv1e 6 ай бұрын
I have same question. Because we consider that the rows are different if they differ in at least one column.
@rahulchandra759
@rahulchandra759 Ай бұрын
Can you pls share create table and data scripts ? not sure if you have already shared somewhere
@Development-fz5vq
@Development-fz5vq Ай бұрын
Thank you for creating this video. It was excellent. In Question 10, the 3rd union should also consider 'CREATED'. d2.status in ('DELIVERED','CREATED'))
@vijaykumar-vp7mx
@vijaykumar-vp7mx 6 ай бұрын
Can you make videos on sql developer Road map to be a sql developer please
@kumaresanigator
@kumaresanigator 5 ай бұрын
alternative for Q10: SELECT CUST_NAME, CASE WHEN TOT_CNT = DELIVER_CNT THEN 'DELIVERED' WHEN DELIVER_CNT > 0 THEN 'IN PROGRESS' WHEN TOT_CNT = submit_cnt THEN 'AWAITING PROGRESS' ELSE 'AWAITING SUBMISSION' END STATUS FROM ( select cust_name, sum(case when status = 'DELIVERED' then 1 else 0 end ) as deliver_cnt, sum(case when status = 'SUBMITTED' then 1 else 0 end ) as submit_cnt, count(order_id) tot_cnt from cust_orders group by cust_name )
@davestorm6718
@davestorm6718 Ай бұрын
you need to add color to your delete queries - it won't work unless you group by ALL fields (excluding the id), otherwise, you'll delete a non-dup record
@ankitgangwar9082
@ankitgangwar9082 Ай бұрын
For query 2 the question we have to find min and max salary of evey department then in that case very dept. Will have two rows and the final output will have 8 rows but your output has 10 rows, pls do correct me if i am wrong
@gautham8364
@gautham8364 3 ай бұрын
in question 3 what if the rows are not arranged car-wise, car1,car2,car3, then the lagging query would be wrong?
@vinayakyerekar762
@vinayakyerekar762 6 ай бұрын
Please Explain query No. 6 in detail.
@Kiba_kua
@Kiba_kua Ай бұрын
Are these questions asked in Business Analyst position as well?
@srishanvithatrendingcollection
@srishanvithatrendingcollection 6 ай бұрын
Hi Toufiq is there any new session start for python beginners from this December. I'm from india
@techTFQ
@techTFQ 5 ай бұрын
Probably from Jan
@mohammadshahbaz3287
@mohammadshahbaz3287 4 ай бұрын
Hi Taufiq, My simpler solution - with base as( select cust_name , count(distinct case when status='DELIVERED' then order_id end) as DELIVERED , count(distinct case when status='SUBMITTED' then order_id end) as SUBMITTED , count(distinct case when status='CREATED' then order_id end) as CREATED , count(distinct order_id) as tot_orders FROM cust_orders group by 1) select cust_name, case when tot_orders=DELIVERED then 'COMPLETED' when tot_orders>DELIVERED AND DELIVERED>0 then 'PROGRESS' when tot_orders=SUBMITTED then 'AWAITING PROGRESS' ELSE 'AWAITING SUBMISSION' END AS FLAG FROM BASE;
@abhijitvernekar593
@abhijitvernekar593 6 күн бұрын
select * from src_dest_distance where source
@prikshitbatta
@prikshitbatta 2 ай бұрын
In question 2, I think there is no need for frame clause?
@michellexu2675
@michellexu2675 Ай бұрын
for first question, can we use SELECT DISTINCT* FROM cars
@jagadishgorijala1513
@jagadishgorijala1513 5 ай бұрын
Pls let us know when you are going to start Advance SQL Advance level 2024
@udhaybhaskarbellamkonda1678
@udhaybhaskarbellamkonda1678 6 ай бұрын
Hi Taufiq When will you start Python Bootcamp let me know pls
@techTFQ
@techTFQ 5 ай бұрын
Sure Ill be announcing in LinkedIn probably next month
@Prasanthi1984
@Prasanthi1984 6 ай бұрын
in your vlog employee table creation script is not working for 2019 version ,fyi
@HughQB
@HughQB 6 ай бұрын
can we get the db data your using in the video?
@Learn_lane
@Learn_lane 6 ай бұрын
11.00
@ashthekool7
@ashthekool7 6 ай бұрын
Hello! For the question on ungrouping data, I am unable to execute the recursive cte on SQL Server. I get an error 'The statement terminated. The maximum recursion 100 has been exhausted before statement completion.' Is there another way to do that? Thanks!
@ashthekool7
@ashthekool7 6 ай бұрын
Actually, I found it. I was missing the termination condition total_count > 1 and that helped solve the above problem. 🙂
@tanmayhadke9161
@tanmayhadke9161 6 ай бұрын
Can I know which IDE do you use for SQL?
@techTFQ
@techTFQ 5 ай бұрын
PG Admin
@kumaresanigator
@kumaresanigator 6 ай бұрын
Alternative Q4 solution: select distinct substr(src_desc, 1, instr(src_desc, '-', 1, 1) -1 ) as source, substr(src_desc, instr(src_desc, '-', 1, 1) + 1 ) destination, distance from ( select destination, source, distance, case when source > destination then source || '-' || destination else destination || '-' || source end src_desc from src_dest_distance )
@vijayreddy5328
@vijayreddy5328 5 ай бұрын
Below also easy alternatives : select least(startingpoint,endingpoint),greatest(startingpoint,endingpoint),distance from distance; OR select startingpoint, endingpoint, distance from ( select startingpoint, endingpoint, distance,row_number() over (partition by distance order by distance) as rn from distance )where rn=1;
@rohandevang5530
@rohandevang5530 5 ай бұрын
Easy Query... SELECT distinct least(source, destination) AS source, greatest(source, destination) AS destination, distance FROM src_dest_distance;
@SubhashreeMB
@SubhashreeMB Ай бұрын
Hi. For the question 1..can someone lemee know if this solution works. delete from cars where model _id in (select max(model_id) from cars group by model name, brand)
@abhijitvernekar593
@abhijitvernekar593 6 күн бұрын
with recursive cte as (select id,item_name,total_count,1 as level from travel_items union select c.id,c.item_name,c.total_count-1,c.level+1 from cte c where total_count>1) select * from cte order by item_name
@kshitijadeshmukh6800
@kshitijadeshmukh6800 6 ай бұрын
Best video, I have faced a few of these exact questions from this video in my interviews. Thank you @techTFQ
@techTFQ
@techTFQ 5 ай бұрын
Welcome:)
@mitul2312
@mitul2312 6 ай бұрын
Query 2 can also be written as, a small change Select *, max(salary) over (partition by dept order by salary desc ) as highest_salary, min(salary) over (partition by dept order by salary) as lowest_salary from employee;
@ksofficerofficer7858
@ksofficerofficer7858 6 ай бұрын
Could you help me I'm struggling joins
@WojMen
@WojMen 5 ай бұрын
why not use cross join for query 6? select t2.team_name, t1.team_name as enemy_team from teams as t1 cross join teams as t2 where t1.team_name not like t2.team_name
@akramhusain5768
@akramhusain5768 6 ай бұрын
Do you have any sql course I want to learn sql to you.
@techTFQ
@techTFQ 6 ай бұрын
I have recordings from my previous bootcamp: techtfq.graphy.com/courses/Recordings-from-SQL-Bootcamp-64f0e1cae4b014d5beccb78e
@alexjenkins8026
@alexjenkins8026 4 ай бұрын
Q3: if days >= 10 anywhere your code will fail as it's a string and will be ordered 1, 10, 2, 3, 4. Q4: if not all source and destinations are duplicated you will remove records that only appear once. Use LEFT JOIN to ensure you're not deleting data. Q5: recursion is very slow, newer SQLs will have a work-around: SELECT id, item_name FROM travel_items CROSS JOIN LATERAL (SELECT EXPLODE(SEQUENCE(1, total_count)) AS num) ORDER BY id, num
@sktneer
@sktneer Ай бұрын
I am new to SQL so sorry if I am asking anything silly. Will these queries also work same way for the SQL server also?
@sravanipattanaik
@sravanipattanaik Ай бұрын
Yes
@sktneer
@sktneer Ай бұрын
@@sravanipattanaik Thanks for replying!
@luwammhreteab2606
@luwammhreteab2606 6 ай бұрын
is that free coures or with paying
$10,000 Every Day You Survive In The Wilderness
26:44
MrBeast
Рет қаралды 83 МЛН
🍟Best French Fries Homemade #cooking #shorts
00:42
BANKII
Рет қаралды 41 МЛН
1 класс vs 11 класс (неаккуратность)
01:00
The delivery rescued them
00:52
Mamasoboliha
Рет қаралды 6 МЛН
6 Intro to Power BI
20:42
Value Driven Analytics Training
Рет қаралды 9
Crack the Top 25 SQL Interview Questions - KSR Data Vizon
32:47
KSR Datavizon
Рет қаралды 187 М.
EASIEST WAY TO BECOME A DATA ANALYST
15:10
Mo Chen
Рет қаралды 33 М.
$10,000 Every Day You Survive In The Wilderness
26:44
MrBeast
Рет қаралды 83 МЛН