Solving SQL Interview Queries | Tricky SQL Interview Queries

Поделиться
HTML-код
  • Опубликовано: 25 ноя 2024

Комментарии • 478

  • @ManuelrPM24
    @ManuelrPM24 Год назад +17

    For the second one in oracle this query also does the trick in one single query
    SELECT NVL(A.ID,B.ID) AS ID,
    CASE WHEN B.NAME IS NULL THEN 'New in Source'
    WHEN A.NAME IS NULL THEN 'New in Target'
    ELSE 'Mismatch'
    END as Comment1
    FROM source A
    FULL JOIN target B ON A.ID = B.ID
    WHERE NVL(A.NAME,'$') NVL(B.NAME,'$');
    I used full join and excluded the names that matched then is just added the Case.
    Great Video!

  • @vlog.444
    @vlog.444 7 месяцев назад +4

    அருமையான எஸ் பி எல் வினாவல் அருமையான எஸ் பி எல் லாங்குவேஜ் சொல்லி கொடுத்ததற்கு நன்றி

  • @lakshmipriya8416
    @lakshmipriya8416 Год назад +30

    I am really thankful to you .. few months ago I was not so confident on myself to give interviews.. after started learning from your videos given around 4-5 interviews confidently. Thank you😊..

  • @darshpancholi4919
    @darshpancholi4919 2 года назад +17

    Please add this video to the SQL playlist! Started watching the joins video and I have never seen a better explanation before. Love the content!

  • @HotThupka
    @HotThupka 2 года назад +10

    He is a savior. I am lucky that I came across his videos. Such a lucid explanation. Thank You. Please upload more of SQL Queries needed for Data Science Folks !!

    • @techTFQ
      @techTFQ  2 года назад +2

      Glad you liked my contents :) thank you

    • @HotThupka
      @HotThupka 2 года назад +1

      @@techTFQ My Pleasure, its for my benefit

  • @westgot2
    @westgot2 2 года назад +1

    I wouldn't ever hire the one who solves the second task like you did.
    This is the clear task for the FULL JOIN

  • @siddheshaddarkar4074
    @siddheshaddarkar4074 7 месяцев назад +1

    Logic is correct... In second query you have used union operators and same table is scanned 3 times which may not be suitable for big tables... We can use cte for the same

  • @rhys4473
    @rhys4473 4 месяца назад +1

    That last example was lit! I was having difficulty understanding recursive CTEs before, but now I clearly get it.

  • @srushtiOm
    @srushtiOm 6 месяцев назад +1

    I could come up with this -
    select comment from (select * from comments_and_translations
    where translation is null) x
    union
    select translation from (select * from comments_and_translations
    where translation is not null) x

  • @bedaprakash9609
    @bedaprakash9609 Год назад +1

    I just got to know He is from Malesiya , such really amazing contents not finding anywhere in youtube , please keep posting more videos like this 🙏🏻🙏🏻, really feeling like big brother is helping to understand such complex things in a simpler way 😇, Love from India 🥰

  • @harsohrabsingh8020
    @harsohrabsingh8020 Год назад +2

    The best channel to learn sql topics as well as solve questions.

  • @madhusudhanreddyt2838
    @madhusudhanreddyt2838 2 года назад +15

    The way you explained and the pain you have taken to make such wonderful videos is way beyond saying thanks...you are a rockstar man....keep posting such kind of tricky queries...will help someone get a job...all the best bro...

    • @techTFQ
      @techTFQ  2 года назад

      Thanks a lot bro

  • @klokeswarreddy3205
    @klokeswarreddy3205 2 года назад +18

    Sir, can you explain about what exactly a sql/ plsql developer do in software industry and what are the career growth options in future for sql developers in IT industry. Is it better to go through in that domain?

  • @Joinwithmeakhilreddy
    @Joinwithmeakhilreddy 2 года назад +4

    You are really explaining the complex queries which will be very helpful for professionals as well

    • @techTFQ
      @techTFQ  2 года назад

      Glad you liked it

  • @karthikvenkataram4790
    @karthikvenkataram4790 Год назад +8

    Thanks a lot TFQ. Your videos is not just a video it is a service for many techs like me. Beautiful explanation that too for tricky questions. More than that the SQL commands to execute and practice in our IDE's that you share get me more to my fullest satisfaction. A special thanks for that too buddy.
    Please keep up the good work.

  • @Hsalz
    @Hsalz 9 месяцев назад +1

    You are simply amazing, Thoufiq! I took your SQL Bootcamp last year and often come back to your content for additional practice and learning. Stay blessed!

  • @cococnk388
    @cococnk388 Год назад +1

    Thanks TFQ the last question was everything, I was blocked on how to remove mirror effect records from my query.

  • @sumitbarde3677
    @sumitbarde3677 2 года назад +2

    hi taufiq, the approach for 3rd problem was out of the world. thanks for such a mind-blowing approach.

    • @techTFQ
      @techTFQ  2 года назад

      Thank you Sumit :)

  • @ashutoshkumar-gv7wu
    @ashutoshkumar-gv7wu 2 года назад +2

    Kindly come up with real life Day to day activity a SQL Developer or a data analyst does in the industry or the company. Like please explain when we join any company how are these Query useful there with some kind of live examples. For instance how a data analyst uses SQL in his day to day work at the office. Also please continue providing such videos and please come up with full tutorial videos in a sincere format like a course

    • @techTFQ
      @techTFQ  2 года назад +1

      Noted on the request bro, let me think about it

  • @archana-sv1hh
    @archana-sv1hh 9 месяцев назад +1

    Hey Taufiq, Could you please make a video on indexing .You explain very well. Want to understand SQL indexing thoroughly but couldn't find any video on your channel. If you already have made video on it, could you please share the link here?

  • @ektashah07
    @ektashah07 Год назад +1

    query 2: without joins
    select id , case when id = 3 then 'new in source' else 'mismatch' end as output from source where id in(3,4)
    union
    select id ,'new in target' as output from target where id in (5) OR
    select id , decode (id ,3,'new in source',4,'mismatch') as output from source where id in(3,4)
    union
    select id ,'new in target' as output from target where id in (5);

  • @sparshmittal705
    @sparshmittal705 2 года назад +2

    Hi sir, we can write it like this select id , case when id=3 then "New in source"
    When id =4 then "New in target"
    When id =5 then "mismatch"
    End as comment
    From source
    Full outer join target
    Where source.nametarget.name

    • @techTFQ
      @techTFQ  2 года назад +1

      Yes right.. I have provided solution using full outer join in my blog

  • @Kabboch
    @Kabboch 2 года назад +3

    For question 1 I would use
    Select isnull(translation, comment) from table

  • @tarunsaha439
    @tarunsaha439 2 года назад +3

    Great explanation. Looks like for the third query you had already solved the second part first using not equal on team names.

    • @techTFQ
      @techTFQ  2 года назад +1

      I did but I wanted to provide a more meaningful and easier to understand solution at the end hence used row number concept

  • @Venkat.devisetti
    @Venkat.devisetti Год назад +2

    Nice question and answers
    However the third question can be solved without rownumber()
    as the < can be directly applied on team code

    • @mdsohail9005
      @mdsohail9005 Месяц назад

      Not exactly, it depends on the lexicographical order if you want do it that way.

  • @VibeQueen24
    @VibeQueen24 6 месяцев назад +1

    Thank you sir, for making such informative videos. it's really helping me practice for my upcoming interviews. One request is to please make videos on puzzles and guesstimates for full practice for the role of data analyst.

  • @2011var
    @2011var Год назад

    God bless you. Taking your precious time and helping others.

  • @gyanprakashmishra9132
    @gyanprakashmishra9132 Год назад

    you are best educator ever for sql 🙏

  • @debasismohanty1311
    @debasismohanty1311 9 месяцев назад

    Really you are born to teach .just loved your way of explaining Thank you so much

  • @misterihorror1993
    @misterihorror1993 2 года назад

    there's many way to do the second query.. it's pretty easy.. the third one now that is challenging!

  • @shivashankargopal1678
    @shivashankargopal1678 2 года назад +3

    Thanks a lot TFQ for giving such wonderful explanation for all these questions.
    I started watching your YT channel a month back your teaching style and your logical explanation for each concepts MINDBLOWING.
    Thank you again for sharing your knowledge.

    • @techTFQ
      @techTFQ  2 года назад +1

      Thank you for the kind words bro 🙏🏼🙏🏼

  • @maidelfigueredo4596
    @maidelfigueredo4596 Год назад

    Thanks for your videos, very helpful for me when I started to find a job. Thanks a lot

  • @ganeshv791
    @ganeshv791 2 года назад +18

    Hi, Your videos are very unique and easy to learn
    Can you please make videos related to Grouping sets, Rollup, Within group.
    And also please make related to dynamic sql
    Thanks for your time.

    • @techTFQ
      @techTFQ  2 года назад +6

      Thank you bro and noted on the request

  • @srinubathina7191
    @srinubathina7191 Год назад

    the way you explained is next level Sir Thank You so much

  • @ctnrandhawa7019
    @ctnrandhawa7019 2 года назад

    great your way of explaining problem and solving them adds fun for them also who thinks sql very tough .great job sir.

  • @yrrep27
    @yrrep27 2 года назад +12

    Alternate solution for problem 2 in postgres--
    It's essentially 3 steps:
    1 Use a FULL OUTER JOIN on id to combine all the records
    2. Use WHERE to pick out the rows where a) Source has a null id, b) Target has a null id, or c) Source name differs from Target name.
    3. Use two CASE statements in SELECT to pick out the non null data and hard code in our comments.

    • @007SAMRATROY
      @007SAMRATROY 2 года назад +1

      The conditions can directly be used in the case statement I think.

    • @PeachesO-NE
      @PeachesO-NE Год назад

      Then Order By DESC COMMENTS

  • @zishan53
    @zishan53 2 года назад +1

    Nice one I feel very relax to solve them
    Thanku very much

  • @rakeshkumarrout2629
    @rakeshkumarrout2629 2 года назад +1

    Guyz watch everyday Data science channel where he already solved so many leetcode interview questions.. Probable qsn for interview.. Do watch tfq.. Of you stuck somewhere get help there.

    • @techTFQ
      @techTFQ  2 года назад

      Thank you Rakesh :)

  • @odaya9946
    @odaya9946 2 года назад +1

    Your exemples with the excel really helped understand the logics, thanks!

    • @techTFQ
      @techTFQ  2 года назад

      Glad you liked it

  • @sathishkumar-yd3pk
    @sathishkumar-yd3pk 2 года назад +1

    Very smart query. Thanks for sharing this query

    • @techTFQ
      @techTFQ  2 года назад

      Your welcome buddy

  • @krishpoptani7862
    @krishpoptani7862 5 месяцев назад

    The video is quite informative, and way of teaching is great.

  • @XxLenasXx
    @XxLenasXx Год назад

    This guys explanation is perfect and amazing

  • @deepaksoni2667
    @deepaksoni2667 2 года назад +2

    your videos helps me a lot to solve complex queries...

    • @techTFQ
      @techTFQ  2 года назад

      I am glad to hear that buddy

  • @darshanwala5561
    @darshanwala5561 Год назад

    very helpful all the sql queries examples thanks brother please share more the complex sql queries real life examples

  • @bmanikanndan
    @bmanikanndan 2 года назад

    Awesome Explanation on Third Query... Thank You so much.

  • @user-lk7zt8cp2g
    @user-lk7zt8cp2g 2 года назад +1

    How to split a string into 2 strings and make first and second as capital letter. Example goodmorning(no space) -Good Morning

  • @ermanojku
    @ermanojku 3 месяца назад

    case- when -then- else ....like if ,elif, else condition (python )

  • @swarnalatha-t6n
    @swarnalatha-t6n Год назад

    hello all , here is my query with easy understanding for the last IPL match query . For each team play with every other team twice , here we can use cross join ... select IPL.team_name , O.team_name from IPL ,IPL as O
    Where IPL . teamcode O. teamcode
    I never imagined that i can also write a query with understanding SQL thank you techTFQ

  • @rameshchavda4117
    @rameshchavda4117 2 года назад +1

    dear ftq salute on your explanation on sql subject

    • @techTFQ
      @techTFQ  2 года назад

      Thank you buddy

  • @infamismworldwild6248
    @infamismworldwild6248 6 месяцев назад

    Thank you this was powerful and expanded my understanding on the application of SQL

  • @NageshwariShankarappa
    @NageshwariShankarappa 4 месяца назад

    good explanation with all examples. Thank you

  • @rajasekharareddyb668
    @rajasekharareddyb668 2 года назад

    Really good explanation.. easy to understand even the problem is very complex.. thank you so much for your time

  • @ruheequreshi9741
    @ruheequreshi9741 Год назад

    you have excellent way of explaining the query and how system works.. really great videos.. good work

  • @nishapandit5131
    @nishapandit5131 Год назад

    Wonderful expiations, especially the last question has a newer nuance..

  • @Sunny-ok7dl
    @Sunny-ok7dl Год назад

    Amazing explanation, these 37 minutes were totally productive

  • @SunithaRamalingam
    @SunithaRamalingam 4 месяца назад

    very very helpfull, thank you. will be usefull if more such videos are brought out

  • @jitendrashelar4123
    @jitendrashelar4123 Год назад

    Excellent! Thank you very much. Such a hard concept to understand, you made so easy sir.

  • @aryanaboyaryayeenezhad7295
    @aryanaboyaryayeenezhad7295 2 года назад +2

    Good job Towfiq Jan!

    • @techTFQ
      @techTFQ  2 года назад

      Glad you liked it bro

  • @waghdipak2358
    @waghdipak2358 2 года назад +1

    really, very appreciative video and the channel itself fro learning sql.
    Thanks a lot sir for providing this.

    • @techTFQ
      @techTFQ  2 года назад

      Thanks you Wagh :)

  • @zacharyrohrback
    @zacharyrohrback 8 месяцев назад

    Thank tou for serving us the knowledge we need!

  • @traumegaz
    @traumegaz Год назад

    thanks teacher, im learning alot your a great teacher

  • @shekhark1139
    @shekhark1139 5 дней назад

    Useful video, really helps for learning as well as for interview, great job ya, please post more videos.... 🙂. It helps alot

  • @bhanuchandarpitlaravi
    @bhanuchandarpitlaravi 2 года назад

    Ur way of explanation is super,
    Keep go like this sir

  • @shaikusman536
    @shaikusman536 Год назад

    Just loved the way you teach....thanks a ton brother....Respect from INDIA.

    • @bedaprakash9609
      @bedaprakash9609 Год назад

      I just got to know He is from Malesiya , such really amazing contents not finding anywhere in youtube.

  • @pratyakshaparashar5306
    @pratyakshaparashar5306 2 года назад +1

    Thanks. Thanks a lot. Your concepts are easily understandable.

    • @techTFQ
      @techTFQ  2 года назад

      Glad to hear that bro

  • @souvikmaitra6653
    @souvikmaitra6653 Год назад

    We want more n more videos like this... excellent work...keep it up ...

  • @abhishekgowda1776
    @abhishekgowda1776 2 года назад +1

    Thank you for sharing another great video..
    Please make video on data import, export and back-up.
    Thanks for your time..

    • @techTFQ
      @techTFQ  2 года назад +1

      Thank you Abhishek and sure will do :)

  • @suryakantchavan4887
    @suryakantchavan4887 2 года назад +1

    Words are not enough to say thank you , love this bro , GBU

    • @techTFQ
      @techTFQ  2 года назад

      Glad you liked it buddy :)

  • @benlong1062
    @benlong1062 Год назад

    This video was really interesting. Your explanations are great! Thank you

  • @ankitapriya13
    @ankitapriya13 2 года назад +1

    Sahi video, sahi samay par!

    • @techTFQ
      @techTFQ  2 года назад

      Hope this helps 👍

  • @amanadhikary8030
    @amanadhikary8030 2 года назад +5

    it was amazing learning. Please make something on normalization if possible

    • @techTFQ
      @techTFQ  2 года назад +2

      Thank you and will consider your request

    • @Ravi-kq1nc
      @Ravi-kq1nc 2 года назад

      It will be very helpful

  • @satyabadiraut1191
    @satyabadiraut1191 2 года назад +1

    Excellent explanation...thank u so much for such kind of sessions.

    • @techTFQ
      @techTFQ  2 года назад

      Most welcome bro!

  • @utubemovies1
    @utubemovies1 Год назад

    The 3rd question is very good.

  • @sauravrajchaudhary9036
    @sauravrajchaudhary9036 2 года назад +1

    Nice keep posting such videos .
    Please share video about complex topic in sql

    • @techTFQ
      @techTFQ  2 года назад +1

      Thank you Saurav and will do

  • @NeverStopLearning56
    @NeverStopLearning56 2 года назад +1

    Hi ,
    Please make a Vedio on Normalisation and Indexing , everywhere they ask these concepts

    • @techTFQ
      @techTFQ  2 года назад

      noted, will plan it

  • @nivedhaputhumaipriyan5769
    @nivedhaputhumaipriyan5769 2 года назад +1

    Excellent.... it's completely worth spending time in watching your videos. . .

  • @nirmaldas4749
    @nirmaldas4749 2 года назад +2

    excellent work sir !! please come with more practical example like this ,,

    • @techTFQ
      @techTFQ  2 года назад +1

      Thank you Das and will do

  • @anduamlaktadesse9284
    @anduamlaktadesse9284 Год назад

    Well presented and solved ! Mnay thanks TFQ !

  • @naveensinghrajput6903
    @naveensinghrajput6903 Год назад

    its great to learn this query

  • @bharatk212
    @bharatk212 2 года назад +1

    Just Awesome Brother ! SQL is an ocean and you're helping others to voyage !!

    • @techTFQ
      @techTFQ  2 года назад +1

      Thank you buddy

  • @pranavkmishra
    @pranavkmishra 2 года назад

    awesome. would like more such videos

  • @ratneshraj4653
    @ratneshraj4653 2 года назад +2

    Very nice, Please make videos on Stored procedure and User defined functions wrt its usage in job.🙏

    • @techTFQ
      @techTFQ  2 года назад +1

      Thank you and sure will do

  • @sulaimansheikh6050
    @sulaimansheikh6050 2 года назад +2

    Hello, You are doing a great job with a good explanation. please make a detailed video on Database Performance Tuning

    • @techTFQ
      @techTFQ  2 года назад

      Thank you Sulaiman and sure will do

  • @timopheim5479
    @timopheim5479 Год назад +3

    Solving question 2 you should perform a full outer join, select rows that have null values in either source or target name or names that mismatch. and use an ifelse function to name the occurences in the variable Comment. Here is the code (with data) using data.table package in R:
    library(data.table)
    x1=c(1,2,3,4)
    x2=c("a","b","c","d")
    y1=c(1,2,4,5)
    y2=c("a","b","x","f")
    X=data.table(id=x1,name=x2)
    Y=data.table(id=y1,name=y2)
    merge(X,Y,by="id",all=TRUE)[name.x!=name.y | is.na(name.x) | is.na(name.y),.(id=id,Comment=ifelse(is.na(name.y),
    "New in Source (X)", ifelse(is.na(name.x),"New in Targe (Y)","Mismatch")))]

  • @anandhvdm6957
    @anandhvdm6957 2 года назад +3

    Sir, Could you please make a video on Index in SQL? How it will be useful in real time?

    • @techTFQ
      @techTFQ  2 года назад +1

      Sure will do

  • @kanchidoshi6907
    @kanchidoshi6907 2 года назад

    For 2 Q -
    select
    case
    when id1 is not null and id2 is null then id1
    when id2 is not null and id1 is null then id2
    when id1=id2 then id1 end as ID,
    case
    when name1 is not null and name2 is null then 'New in Source'
    when name1 is null and name2 is not null then 'New in Target'
    when id1=id2 and name2name1 then 'Mismatch' end as Comment
    from
    (select s.id as id1,s.name as name1,t.id as id2,t.name as name2
    from source s
    full outer join target t
    on s.id=t.id
    where s.id is null or t.id is null or
    (s.id=t.id and s.namet.name))x

    • @techTFQ
      @techTFQ  2 года назад

      thats right. Ive provided similar solution in my blog too for this question

  • @Anbumanie3011
    @Anbumanie3011 9 месяцев назад

    I got some tricky SQL queries with answers,
    I hope it will help me

  • @srujanjajala
    @srujanjajala 2 года назад +1

    very helpful tutorial with realistic examples..

    • @techTFQ
      @techTFQ  2 года назад +1

      Thank you buddy

  • @mohan_kannadiga
    @mohan_kannadiga Год назад

    Brilliant Query approach

  • @anirbansarkar6306
    @anirbansarkar6306 2 года назад +1

    This is really wonderful video. Thank you so much. Please do come up with such wonderful contents.

    • @techTFQ
      @techTFQ  2 года назад

      Thank you bro

  • @guzmanerpr
    @guzmanerpr 11 месяцев назад

    Thank you for taking your time to explain this.

    • @techTFQ
      @techTFQ  11 месяцев назад

      Glad you liked

  • @amit.pawase007
    @amit.pawase007 2 года назад +2

    Thank you so much for the thoughtful explanation. 😊
    One thing came into mind, 2nd query with union of 3, instead, can we use full join with case statement to print the desire output?

  • @nikhilreddy4582
    @nikhilreddy4582 2 года назад +1

    Totally different , easy to understand 👌

    • @techTFQ
      @techTFQ  2 года назад

      Thank you 🙏🏼

  • @priyaranjan9358
    @priyaranjan9358 2 года назад +2

    It's really helpfull. Thank you...

    • @techTFQ
      @techTFQ  2 года назад

      Thank you 🙏🏼

  • @prajaktawagh2626
    @prajaktawagh2626 2 года назад +1

    I am always eagerly waiting for your next vedio.. to learn new things.. keep going..

    • @techTFQ
      @techTFQ  2 года назад +1

      Thank you for the support Prajakta 🙏🏼
      Appreciate it ☺️

  • @Gruder47
    @Gruder47 2 года назад

    My version of problem 2:
    select
    ID
    ,Case when ID = 3 then 'New in source'
    when ID = 4 then 'Mismatch'
    when ID = 5 then 'New in target'
    End as Comment
    from source
    where ID in (3,4,5)
    union
    select ID
    ,Case when ID = 3 then 'New in source'
    when ID = 4 then 'Mismatch'
    when ID = 5 then 'New in target'
    End as Comment
    from target
    where ID in (3,4,5)

  • @prasadankulwar6050
    @prasadankulwar6050 2 года назад

    Really appreciate your efforts on this sir..🙏

  • @tinurathi5210
    @tinurathi5210 2 года назад

    Thank you .. for the great explanation!

  • @vibhanshudongre
    @vibhanshudongre Год назад

    For the last we can use cross join
    select t1.team_name as team, t2.team_name as opponent from teams t1
    cross join teams t2
    where t1.team_name t2.team_name
    This will give the result for each team playing against each other twice.

  • @satyashivmodi6945
    @satyashivmodi6945 Год назад

    Loved you. Amazing session and videos. Love you more. Thanks a ton. You get lot of fame and money and you are amazing. God bless you.