3 SQL Queries Asked in Interview for Business Analyst - Solved

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 ม.ค. 2025

ความคิดเห็น • 119

  • @sidheshbhambid4023
    @sidheshbhambid4023 ปีที่แล้ว +17

    No one can make SQL look so easy! Totally worth learning SQL from your recent boot camp cohort 2. The way you approach and solve complex queries by breaking them down into smaller parts was the most important thing I learned from you! ♥
    Keep bringing such content, this is what raises my confidence even more in SQL!! 😅🙌

  • @rishabh_fitness3273
    @rishabh_fitness3273 ปีที่แล้ว +5

    hands down!! what a genius you are ! specially the third problem and the explaination just wow,,, taufiq sir because of you , i have cleared many concepts of sql...may god bless you taufiq

  • @fenix6627
    @fenix6627 ปีที่แล้ว +4

    After a week of watching your lessons, I was able to solve these queries for myself, thanks a lot.

    • @techTFQ
      @techTFQ  ปีที่แล้ว

      Great 👍

  • @sravikav1018
    @sravikav1018 11 หลายเดือนก่อน +1

    It's really awesome explanation and this is the best SQL channel i have ever got,thanks a lot for sharing the knowledge. Looking forward for the more videos with SQL examples.

  • @dingaroo2003
    @dingaroo2003 11 หลายเดือนก่อน

    Greetings brother, from Singapore. As a working adult who is doing self-study, such exercises with step-by-step solutions are extremely priceless! Thank you Taufiq.

  • @narendra742
    @narendra742 2 หลายเดือนก่อน +1

    very nice problems and excellent solutions with great explanation. Great job

  • @devarapallivamsi7064
    @devarapallivamsi7064 9 หลายเดือนก่อน +6

    I am seriously gonna laugh at people if they opt for any paid course of SQL even after coming across your channel.
    Hands down I would choose you over anyone to learn SQL from.

  • @yi-lehung6311
    @yi-lehung6311 ปีที่แล้ว +6

    Such great SQL content videos! I can always learn things from your videos. Shoutout to techTFQ!

    • @techTFQ
      @techTFQ  ปีที่แล้ว

      Happy to hear that! Thank you so much

  • @vasimahamadshaikh3730
    @vasimahamadshaikh3730 ปีที่แล้ว +1

    Toufiq bhai what explains yaar . Everyone should understand what you want to give us from this video.great Bhai

    • @techTFQ
      @techTFQ  ปีที่แล้ว +1

      Thank you so much bro 😀

  • @ST-actual
    @ST-actual ปีที่แล้ว +2

    Super useful. I’m relating everything I learn about SQL to New Relic which is what my company uses for observability.

    • @techTFQ
      @techTFQ  ปีที่แล้ว

      Thank you very much 😊

  • @hameedshaik-o2m
    @hameedshaik-o2m 11 หลายเดือนก่อน

    Thank you Toufiq bhai, the way that you explained queries is so good and i hope who don't have any knowledge on sql they will easily to understand

  • @sakshipandey5137
    @sakshipandey5137 ปีที่แล้ว +1

    Excellent explanation!!💯 Thankyou for making our life easy. God bless you!

  • @kunalkumar-hl6gv
    @kunalkumar-hl6gv ปีที่แล้ว +7

    this is not intermediate level but yet it is very useful there are so many things to get from this video

  • @riasingh11
    @riasingh11 8 หลายเดือนก่อน +1

    You are the best tech teacher

  • @prakashkathait927
    @prakashkathait927 3 หลายเดือนก่อน

    Amazing Concepts, happy to learn a lot of it from your videos thanks a lot!!

  • @maghy_kethychannel
    @maghy_kethychannel ปีที่แล้ว +4

    Hi toufiq really hats off to your afforts and explanation.plz start an exclusive course on data analytics.

    • @techTFQ
      @techTFQ  ปีที่แล้ว +2

      Thank you bro, I will try my best

  • @mounikathouda
    @mounikathouda 8 หลายเดือนก่อน

    Explaining step by step clearly. Good Video 😊

  • @pvn128
    @pvn128 4 หลายเดือนก่อน

    Thank you very much. You explain things really well and make it easy to follow. I really appreciate it.

  • @saiswaroop3570
    @saiswaroop3570 ปีที่แล้ว +3

    Hi, toufiq your videos on SQL are very good and your explanation is very detailed. It would be helpful if you post more content on SQL like this and share some roadmaps how we can grow with SQL as primary skill.
    Please suggest some good certification courses for SQL that are available online

  • @ThejoPrasad-y5l
    @ThejoPrasad-y5l ปีที่แล้ว

    The way of approach is easy to understand and follow , Thank you so much.

  • @vigneshwarannallasamy
    @vigneshwarannallasamy ปีที่แล้ว +1

    Hi Thoufiq, really loved your videos and learned a lot from you. It will be beneficial if you can share the Cheat Sheet of SQL syntaxes.

  • @sivagowthu859
    @sivagowthu859 ปีที่แล้ว +1

    1st question my way of approach
    with cte as(
    select * from candidate c
    inner join results r
    on c.id=r.candidate_id)
    select party,count(*) as no_of_seats from(
    select *,dense_rank()over (partition by constituency_id order by votes desc) as rn from cte ) dt
    where rn=1 group by party

  • @TheDocValerian
    @TheDocValerian ปีที่แล้ว

    This is a great video. I can only imagine how it is to solve if you had to wtite this on a simple paper as a candidate

    • @techTFQ
      @techTFQ  ปีที่แล้ว

      Thanks:)

  • @nikhilreddy4582
    @nikhilreddy4582 ปีที่แล้ว

    Bro u r a gem... Keep doing many more contents. This help me understand to solve the queries in a more better way. As I have also attempted these queries but failed to solve it. These are from hacker rank got it in a meesho 1st round. These video help me understand much better. Thanks a lot broo...

  • @ManpreetSingh-tv3rw
    @ManpreetSingh-tv3rw ปีที่แล้ว +2

    Query 3 ,MSSQL
    with echo as (select state,candidate_id,count(candidate_id) as seatcount_byid from results_tab
    group by state,candidate_id),
    rt as (
    select *,dense_rank() over (partition by candidate_id order by seatcount_byid desc) as position from echo),
    final1 as (select * from rt
    where position

  • @avinashpratapsingh3875
    @avinashpratapsingh3875 ปีที่แล้ว +1

    Hi @techTFQ in the second query you have use group by clause on alias customer and status, but as per execution order group by is executed before select, so when I tried running query you explained it throws me error invalid identifier, Cn you please let me know what to do. I am using Oracle SQL Developer

  • @m.kirubakaran6564
    @m.kirubakaran6564 ปีที่แล้ว

    Thanks Man..
    very very useful..
    very easy to understand
    Big Thx......

  • @F_A_R_man
    @F_A_R_man ปีที่แล้ว

    Thanks for efforts. Your content is very useful 🥰

  • @pravinbhojane89
    @pravinbhojane89 5 หลายเดือนก่อน

    Nicely explained 🙌🏻

  • @fathimafarahna2633
    @fathimafarahna2633 ปีที่แล้ว +1

    You are as always best 💯 God bless

    • @techTFQ
      @techTFQ  ปีที่แล้ว

      Thank you so much 😀

  • @ManishSharma-fi2vr
    @ManishSharma-fi2vr 9 วันที่ผ่านมา

    Great problem set

  • @ganeshvbidwe
    @ganeshvbidwe ปีที่แล้ว +1

    Oh great video and insightful
    Upload more video about stored procedure and udf functions with exception handling

    • @techTFQ
      @techTFQ  ปีที่แล้ว +1

      Thank you and noted bro

  • @ceejayachky6279
    @ceejayachky6279 ปีที่แล้ว

    You are an excellent teacher.

  • @krishnakantsharma8021
    @krishnakantsharma8021 11 หลายเดือนก่อน

    Wow, you are the best🎉

  • @RoopmathiGunnaubcmba
    @RoopmathiGunnaubcmba ปีที่แล้ว

    The third one was the most challenging for me to get my head around.

  • @YouvashreeKM
    @YouvashreeKM หลายเดือนก่อน

    my Ans :
    Q1.
    select concat(party,' ',count(*)) as seats from (
    select c.party,r.constituency_id,r.votes,
    row_number() over(partition by constituency_id order by votes desc) as rk
    from
    candidates c
    join results r on c.id=r.candidate_id)x
    where x.rk=1
    group by party

  • @Kondaranjith3
    @Kondaranjith3 ปีที่แล้ว +1

    Hi sir string_agg function in postgress but i am using mssql server i could not find the aternative function for it

  • @ambeshpandey8937
    @ambeshpandey8937 7 หลายเดือนก่อน

    First one my approach
    with cte as(select *,
    min(votes) over (partition by constituency_id) as lowest_vote
    from result),
    cte2 as(
    select *,
    (votes-lowest_vote)as vote_diff
    from cte),
    cte3 as (
    select *,
    row_number() over (partition by constituency_id order by vote_diff desc) as rnk
    from cte2)
    select concat(c.party,' ',count(*)) as party_seats from cte3
    join candidate c
    on cte3.candidate_id=c.d
    where rnk=1
    group by c.party

  • @BharathKumar-id8wk
    @BharathKumar-id8wk ปีที่แล้ว +1

    ❤good one

  • @jayantachakraborty4915
    @jayantachakraborty4915 ปีที่แล้ว

    08:48 I did not understand why we used count(1). Could you help me understand?

  • @LokeshKumar-ii1or
    @LokeshKumar-ii1or ปีที่แล้ว

    Hi Sir
    Please do one video for how to retrieve specific data from XML column in Oracle SQL

  • @brunomiguel3533
    @brunomiguel3533 ปีที่แล้ว

    Amazing stuff. Really enjoyed it and learned a lot. 5 stars!

    • @techTFQ
      @techTFQ  ปีที่แล้ว

      Thank you

  • @mkarvj
    @mkarvj ปีที่แล้ว

    You are absolutely amazing sir!!!!

  • @DHA508
    @DHA508 ปีที่แล้ว

    Thanks for awesome session.

  • @Sachin_Sambare
    @Sachin_Sambare หลายเดือนก่อน

    Nice explanation

  • @saswatkumar2517
    @saswatkumar2517 11 หลายเดือนก่อน

    brilliant explanation

  • @dkaustubh
    @dkaustubh ปีที่แล้ว +1

    Great video ❤
    Thanks !

    • @techTFQ
      @techTFQ  ปีที่แล้ว

      Glad you liked it!

  • @jakusam4564
    @jakusam4564 ปีที่แล้ว

    Dear sir ,when your next SQL live bootcamp start?eagerly waiting for this

  • @gayatribhuyan1600
    @gayatribhuyan1600 ปีที่แล้ว +3

    Hi,Can you make some sql interview questions for data engineers.

    • @techTFQ
      @techTFQ  ปีที่แล้ว +1

      let me see if I can find any

  • @murchhanabanerjee26
    @murchhanabanerjee26 11 หลายเดือนก่อน +1

    Hi Taufiq, I am your fan ! You have become the ultimate destination to clear doubts & concept. I want to share 2 sql problems which I couldn't solve in interview. How should I share ? Can't find your email in this chat .

    • @techTFQ
      @techTFQ  11 หลายเดือนก่อน

      Thank you 🙏
      Glad to hear that .. my email techtfq@gmail.com

  • @chaitusai7674
    @chaitusai7674 7 หลายเดือนก่อน

    why have you removed order by clause within cte? in 3rd query? please anyone explain

  • @sugunadammu1283
    @sugunadammu1283 4 หลายเดือนก่อน

    Getting error while using string aggregate function in second question. It is showing that the fuction does not exist. What is the solution for this ?

  • @toshifchhipa8938
    @toshifchhipa8938 2 หลายเดือนก่อน

    Can this be done by using max function to retrieve candidates with most votes in each constituency in sub query then taking count of constituency in main query

  • @kamalikamukherji6482
    @kamalikamukherji6482 ปีที่แล้ว

    Ur the best❤

  • @VpsSvs
    @VpsSvs ปีที่แล้ว

    Do you have any idea of starting PlSql bootcamp?

  • @Al-Ahdal
    @Al-Ahdal ปีที่แล้ว

    Hi I am a professional accountant, and do loads of business analysis, reporting etc in Excel. I would like to learn Business SQL for Data Analytics, kindly share the road map and learning source. Thanks

  • @lalitak9404
    @lalitak9404 ปีที่แล้ว +1

    Here is the query with out window function : Select concat(party,' ',count(*)) from (select constituency_id,max(votes)as votes from candidates c inner join results r on c.id=r.candidate_id group by constituency_id)as temp inner join results r on temp.constituency_id=r.constituency_id and temp.votes=r.votes inner join candidates c on r.candidate_id=c.id group by party;

  • @achunaryan3418
    @achunaryan3418 ปีที่แล้ว

    Excellento.

  • @rimaranimeher9644
    @rimaranimeher9644 ปีที่แล้ว

    Please do more interview questions on mysql

  • @dikshapatiyal5986
    @dikshapatiyal5986 9 หลายเดือนก่อน

    You are Amazing

  • @vermaji5220
    @vermaji5220 ปีที่แล้ว

    with cte as
    (select c.id, c.party,r.constituency_id,r.votes
    from candidates as c
    inner join
    results as r on r.c_id=c.id),
    cte1 as(
    select *
    , rank() over (partition by constituency_id order by constituency_id, votes desc) as rn
    from cte)
    select party, count(1) as won_seat
    from cte1
    where rn=1
    group by party

  • @razikamuthu3795
    @razikamuthu3795 ปีที่แล้ว

    Can you please share next boot camp slots for SQL

  • @balaroxx2700
    @balaroxx2700 7 หลายเดือนก่อน

    String_arg() inside distinct is not a valid in ms sql please give me alternative code😢 19:32 also the order by inside strinģ arg 35:48

  • @varunl6948
    @varunl6948 ปีที่แล้ว

    Thanks for this!

    • @techTFQ
      @techTFQ  ปีที่แล้ว

      You're welcome

  • @ayusheepradhan7110
    @ayusheepradhan7110 3 หลายเดือนก่อน

    Please let me know if its correct or not for 1st question
    with cte as (select party, max(votes) from candidates c
    join results r on c.id=r. candidate_id group by constituency_id )
    select concat(party,' ',count(party)) as party_seats_won from cte group by party;

  • @jetsfromnewjersey1377
    @jetsfromnewjersey1377 ปีที่แล้ว

    Hi taufiq i want to buy sql course but payment portal is not able to accept my card
    itrat ali from NJ USA

  • @favoura5555
    @favoura5555 ปีที่แล้ว

    Why did we join when we already used cte?

  • @ramshabdaramnaresh9438
    @ramshabdaramnaresh9438 ปีที่แล้ว

    In SQL Server string_agg not supporting distinct then how to solve 2nd one

  • @b_rizzle4808
    @b_rizzle4808 ปีที่แล้ว +1

    will using an order by in a cte slow down query performance? or will it just be ignored

    • @techTFQ
      @techTFQ  ปีที่แล้ว

      order by is unnecessary inside a cte because the purpose of cte is to return a resultset, how the resultset is ordered is not necessary. And yes order by will consume some resources so better to avoid it when its not required

  • @Ams_bando
    @Ams_bando 5 หลายเดือนก่อน

    website is not working. any other link for dataset?

  • @chaitusai7674
    @chaitusai7674 7 หลายเดือนก่อน

    select * from(select c.party, count(c.party), rank() over(partition by r.constituency_id order by votes desc) as rnk from candidates c join results r on c.id=r.candidate_id group by c.party) x where x.rnk=1; is this good?

  • @RajeshwarUma
    @RajeshwarUma ปีที่แล้ว

    Thank you so much

  • @promitdutta3029
    @promitdutta3029 ปีที่แล้ว

    how to do string_agg fcn in mysql ?

  • @deepaknayak1195
    @deepaknayak1195 ปีที่แล้ว +1

    Thanks ❤

    • @techTFQ
      @techTFQ  ปีที่แล้ว

      You're welcome 😊

  • @rickymahakul3871
    @rickymahakul3871 ปีที่แล้ว +1

    My age is 32 can I enter into data analyst job if I acquire skills required for this job role

  • @RoopmathiGunnaubcmba
    @RoopmathiGunnaubcmba ปีที่แล้ว

    @TechTFQ: This question is for which company? In India or North America?

  • @rushikeshjoshi9506
    @rushikeshjoshi9506 ปีที่แล้ว +2

    I know this is from hacrkrank interview questions for ETL Testing I faces this all 3

    • @techTFQ
      @techTFQ  ปีที่แล้ว

      nice, good to know

    • @sarvesht7299
      @sarvesht7299 ปีที่แล้ว

      Which company bro ?

    • @pratheesh12
      @pratheesh12 ปีที่แล้ว

      ​@@sarvesht7299meesho

  • @dravidbalaji1373
    @dravidbalaji1373 ปีที่แล้ว

    Super bro

  • @anudeepreddy5559
    @anudeepreddy5559 ปีที่แล้ว

    Plsql bootcamp please

  • @RyanLoh
    @RyanLoh ปีที่แล้ว

    Hi which software are you using to write this SQL code?

    • @techTFQ
      @techTFQ  ปีที่แล้ว

      PostgreSQL DB, PG Admin tool

  • @houcineb4139
    @houcineb4139 ปีที่แล้ว

    thank you

  • @HARSHRAJ-wz2rp
    @HARSHRAJ-wz2rp 6 หลายเดือนก่อน

    with cte as(
    select candidates.*,constituency_id,votes FROM candidates JOIN results ON candidates.id=results.candidate_id
    )
    select constituency_id,party FROM(select constituency_id,party,votes,DENSE_RANK()OVER(partition by constituency_id ORDER BY votes DESC) as "x" FROM cte) as es where es.x=1;

  • @nivisworld1513
    @nivisworld1513 ปีที่แล้ว

    Hai....sir.... please write the querys 1) how to find highest salary of the employee?
    2) query to find 2nd ,3rd,4th ....higest salaries?
    And query to find nth highest salary?

    • @vishalgoswami7512
      @vishalgoswami7512 ปีที่แล้ว

      use rank over order by salary

    • @nivisworld1513
      @nivisworld1513 ปีที่แล้ว

      @@vishalgoswami7512 if u don't mind....can you write?

  • @chandradeep-j2m
    @chandradeep-j2m ปีที่แล้ว

    Can we use count(*) instead of count(1) in my sql?

  • @mohanmuppidi6846
    @mohanmuppidi6846 ปีที่แล้ว

    S man.. It is good

    • @techTFQ
      @techTFQ  ปีที่แล้ว

      Thank you

  • @nivisworld1513
    @nivisworld1513 ปีที่แล้ว

    I know these are the basic qns but i need proper queries plz ...( if anybody see my mes... u can also rply )

  • @Fitness_Gallery
    @Fitness_Gallery ปีที่แล้ว

    Sir please make the video in Hindi because Hindi is familiar for us

  • @rohit_vora
    @rohit_vora 8 หลายเดือนก่อน

    with cte as
    (select row_number() over(partition by party ) rn, c.id, party, constituency_id, votes
    from candidates c
    join results r on r.candidate_id = c.id),
    cte2 as
    (select c1.id, c2.id, c1.party, c1.constituency_id,c2.constituency_id, c1.votes dvot, c2.votes rvot
    from cte c1
    join cte c2 on c1.constituency_id = c2.constituency_id and c1.rn = c2.rn and c1.party c2.party),
    cte3 as
    (select *,
    case when dvot > rvot then 1 else 0 end flag
    from cte2)
    select concat(party, ' ', total) wons
    from
    (select party, sum(flag) total
    from cte3
    group by 1)

  • @farzanahmed5530
    @farzanahmed5530 5 หลายเดือนก่อน

    -- Hi, I tried without CTE, Please check my query sir :-
    SELECT Party, count(*) FROM [dbo].[candidates] WHERE ID IN (SELECT r1.candidate_id from [results] R1, [results] R2 WHERE R1.Constituency_id=R2.Constituency_id and R1.VOTES< R2.VOTES ) GROUP BY Party

  • @MJTECH4U
    @MJTECH4U ปีที่แล้ว

    Appreciate it. @techTFQ