CTE in sql server Part 49

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

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

  • @TheINTERLECT1
    @TheINTERLECT1 9 месяцев назад +15

    I started studying for my Computer Science degree in 2011. In 2014 I relied heavily on this channel to carry out our final year project. I have been working as a Software Engineer since 2015 and to date I still refer to this channel as either a refresher on certain concepts that I forgot or to learn new technologies. God bless Venkat!

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

    Mostly for beginners:- I don't know if anyone has any doubt on " how he joined two tables without having same /related column name/value ?"
    The answer is :- We can join two tables without having Pk / FK concept as long as the columns on the condition have the same data values or it can be converted into the same data value :)
    This video is crystal clear !! Thanks.

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

    It's amazing how relevant Venkat SIR is even after 10 years. I was asked a question on CTE in one of my interview today. Find the third highest salary from an employee table with CTE AS
    (Select distinct Salary, ROW_NUMBER() OVER (order by Salary desc) as ranking from Employees)
    Select salary from CTE where ranking=3

  • @bogdan13grbea
    @bogdan13grbea 9 лет назад +63

    Thank you very much. You should help Microsoft build their courses because they are a mess!You are a bless for us the newbies!!!

    • @eh5773
      @eh5773 9 лет назад +1

      kudvenkat reallyappreciate
      you

    • @Trzbne
      @Trzbne 6 лет назад +5

      It was true 2 years ago, and it is still true now :-) Venkat for Microsoft Virtual Academy!

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

      @@Trzbne AND STILL RELEVANT AFTER 4 YEARS NO DOUBT

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

    CTE's made my life simple! I used to write complex and nested queries for producing complex reports. Now I can easily simplify them using CTE's, which are more simple and maintainable.

  • @sidchakravarty
    @sidchakravarty 9 лет назад +5

    Venkat, I started watching your videos earlier today and I must tell you that your method of instruction is really good. I am preparing for MCSE 70-461 exam and I was struggling with CTE. However, your video made it absolutely clear. I have also placed an order for all of your SQL Server videos. Can't wait to have them downloaded. I am glad to have found your videos!
    Keep up the good work ...

    • @Csharp-video-tutorialsBlogspot
      @Csharp-video-tutorialsBlogspot  9 лет назад +2

      +Sidhartha Chakravarty Thank you so much for the feedback. Means a lot. Glad the videos are useful.
      Dot Net & SQL Server training videos for aspiring web developers
      ruclips.net/user/kudvenkatplaylists?view=1&sort=dd
      Download our training videos and slides for offline viewing
      www.pragimtech.com/Order.aspx
      Code Samples, Text Version of the videos & PPTS on my blog
      csharp-video-tutorials.blogspot.com
      Tips to best utilise our channel
      ruclips.net/video/y780MwhY70s/видео.html
      To receive email alerts, when new videos are uploaded, please subscribe to our channel using the link below
      ruclips.net/user/kudvenkat
      Please click the THUMBS UP button below the video, if you think you liked them
      Thank you for sharing the link with your friends who you think would also benefit from them
      Best
      Venkat

    • @boreroro5356
      @boreroro5356 8 лет назад

      Hello I am also preparing to take MCSE 70-461 exam and if you have taken the exam do you have any advice how to study or any tips .
      thanks

  • @krzysztofs8535
    @krzysztofs8535 7 лет назад +1

    You are the greatest teacher i have ever known. Thank for all you are doin'.
    God bless you.

  • @genemgranstaff
    @genemgranstaff 11 лет назад +10

    Your work and attention to detail are FANTASTIC! Thank you so much for this series. I intend to explore your other topics, as well. THANK YOU SO MUCH!!

  • @lemmiTry
    @lemmiTry 6 лет назад +1

    Your videos are saving me tons of hours that I would otherwise be spending reading books to learn the same!

  • @raviatremiel
    @raviatremiel 7 лет назад +1

    Mr Venkat You are genius man...

  • @soarindragon603
    @soarindragon603 5 лет назад +3

    You can reference the first CTE in the second CTE in the CTE declaration list. That's a very useful feature as you can build on CTE results on each subsequent CTE in the list. A CTE can be referenced within the next select, insert, (...) AND another CTE declared after it under the same WiTH clause.

  • @Djabsey1
    @Djabsey1 11 лет назад

    Wow. Excellent Explanation.Makes it crystal clear. Very confident about my 70-461 exam

  • @muthukumar-hn9wr
    @muthukumar-hn9wr 10 лет назад +1

    It is really amazing and it helps lot to know about the SQL in very short period. Thanks a lot. Keep it up Mr. Venkat. Hats off.

  • @delkaaaa
    @delkaaaa 3 года назад

    best CTE explanation on youtube!

  • @dharmasalana1286
    @dharmasalana1286 6 лет назад

    Explaination and terminology is simple superb. Clear and easy to remember explaination

  • @nimeshambalalpatel3032
    @nimeshambalalpatel3032 3 года назад +1

    My pranams to you venkat sir!!!

  • @yt1234567100
    @yt1234567100 4 года назад

    Thank you, very enjoy it and easy to understand. Very good works from you.

  • @vandyniyomkham5032
    @vandyniyomkham5032 10 лет назад

    this guy is really good at explaining cte

  • @dbin805
    @dbin805 8 лет назад

    Clear and concise explanation. Well done.

  • @sefacihangir8959
    @sefacihangir8959 3 года назад

    Thank you, great explanation in a clear way.

  • @aliazad1118
    @aliazad1118 5 лет назад

    Perfect. Thanks a lot for your time and the best tutorial.

  • @teriyakov
    @teriyakov 10 лет назад

    Agreed, really clear and concise info. Thanks very much for sharing

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

    very detailed explanation ! thanks a lot!

  • @kudakwashehlanga5513
    @kudakwashehlanga5513 5 лет назад

    You the G.O.A.T !!

  • @elliottcooper8552
    @elliottcooper8552 6 лет назад +1

    Sir you have a beautiful voice!

  • @dungnguyenhoanganh4188
    @dungnguyenhoanganh4188 8 лет назад

    Tks my teacher, from Viet Nam

  • @danishhussainomex7896
    @danishhussainomex7896 6 лет назад

    I learned ASP.net, asp.net MVC, SQL server, jquery from you.

  • @christianrodier3381
    @christianrodier3381 5 лет назад

    That was very helpful, thanks. I recommend practicing on MS SQL Server Management Studio. CTEs don't really work well on MS mySQL Workbench

  • @Marselmarsemars
    @Marselmarsemars 7 лет назад

    cool and clear tutorial. definetly subscription

  • @AV-bp3bc
    @AV-bp3bc 2 года назад

    Excellent content 👍

  • @supritshah1289
    @supritshah1289 9 лет назад +6

    You explained very brilliantly topics of CTE, table variable, temp table, views. But I have one question, ie. temp table, table variable and cte are doing same things so which one is best and for what scenario?. In which situation I should use CTE and not views/table variable. I will do my research too but since you're more knowledgable it doesn't hurt to question you.
    Thank you

    • @ManishKumar-qx1kh
      @ManishKumar-qx1kh 3 года назад +1

      I am not sure if this answer will help you now coz its been 6 years since you asked this question but i will still answer just in case somebody else have the same query.
      Derived tables and CTE's do almost the same thing but derived tables scope is within that same query but with CTE u can define the table and use it in the next immediate select insert etc query so in this case ur single query does not becomes complex and big.
      Table variables and temporary tables you can see the differnce on internet there are a lot of difference mentioned. I will mention just the one where u can pass table variables as argument to SP's and all.
      Views you create when u have to use it in future as well not for just one time. Derived tables and CTE's are one time things.
      Hope this answers ur query.

  • @akanshasoni6040
    @akanshasoni6040 8 лет назад +4

    Hi Venkat,
    It was very informative and worth watching video .It would be great if you can share group by with having clause video or else send the link.

    • @SuperGojeto
      @SuperGojeto 8 лет назад

      +Akansha Soni its already there. Check his sql playlist. I think its in between the beginning 20 videos.

  • @Jaipur-Green-Energy
    @Jaipur-Green-Energy 10 лет назад +1

    Thank you very much for this video!

  • @jasonwoodward5501
    @jasonwoodward5501 10 лет назад

    Good stuff mate, good stuff...

  • @Xkce16
    @Xkce16 6 лет назад

    you are great !!

  • @ajithkumar6124
    @ajithkumar6124 3 года назад

    Thanks bro ✌✌

  • @frigzter
    @frigzter 10 лет назад

    Great Explanation - Thank you

  • @gatlarajesh3588
    @gatlarajesh3588 10 лет назад

    nice explanation sir thanq you very much

  • @ReginThangaraj2
    @ReginThangaraj2 11 лет назад

    Good video. Thanks for posting.

  • @saifalimuhammadi2147
    @saifalimuhammadi2147 7 месяцев назад

    i love you voice bro

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

    very helpful

  • @paingcoeus7844
    @paingcoeus7844 7 лет назад

    Thank you so much Sir.

  • @dhaneshpt8641
    @dhaneshpt8641 4 года назад

    Thank you sir.

  • @gurungoracle
    @gurungoracle 10 лет назад

    thank you, very helpful

  • @KayYesYouTuber
    @KayYesYouTuber 8 лет назад

    beautiful explanation

  • @kabeerbindra3061
    @kabeerbindra3061 5 лет назад

    Thanks 🥰

  • @adnanlaswad7586
    @adnanlaswad7586 7 лет назад

    Dear Venkat I just want to correct you (temporary table will destroyed from the database when the connection which created it exist or we can explicitly drop it) thanks

  • @VarunPatwardhan
    @VarunPatwardhan 10 лет назад

    Thanks a lot :)

  • @Venkateshmahendru
    @Venkateshmahendru 7 лет назад

    HI Venkat One question here.. If we can only use CTE just immidately followed with select statement then what is the use of CTE instead of that we can use Temp table.

    • @soarindragon603
      @soarindragon603 5 лет назад +1

      A CTE on its own would replace a derived table (subselect in from clause) not a temp table and you could reference it multiple times in the same select. It makes the code a lot cleaner. You can also reference a CTE in the next CTE listed under the same WITH statement which is very useful as you can build on calculations from one CTE to the next. THE most useful CTEs are the recursive ones. You can replace a lot of loops and cursors with recursive CTEs if you know what you're doing and get enormous increases (100x, 1000x) in performance.

  • @pamaljanveja
    @pamaljanveja 5 лет назад

    Thanks

  • @meghasyam427
    @meghasyam427 3 года назад

    Just wow

  • @sechidambaram
    @sechidambaram 9 лет назад

    Thank you sir..

  • @babaryaseen389
    @babaryaseen389 5 лет назад

    Great

  • @stutitehri993
    @stutitehri993 10 лет назад

    good tutorial

  • @lajapathyarun4329
    @lajapathyarun4329 11 лет назад

    very nice

  • @sivanathanbalasubramanian
    @sivanathanbalasubramanian 10 лет назад

    Thank you for this wonderful tutorial

  • @arizequbal1606
    @arizequbal1606 4 года назад

    Can anyone explain.. I''m confused in the increment part.. why we are incrementing the Level by using +1... the value can be derived from the second table.

  • @BlalKhalidTech
    @BlalKhalidTech 4 года назад

    Hi
    Hope you are fine, I want to ask what is the importance of CTE .we can achieve a result without CTE then why use??

  • @nikhilthenitian
    @nikhilthenitian 9 лет назад

    Hello Sir
    Can you share video regarding Tabled Value Variables

  • @michalroesler
    @michalroesler 3 года назад

    yes.

  • @alikhan-su2jj
    @alikhan-su2jj 3 года назад

    hi, can we use insert/update/delete in SQL Functions,

  • @MrSachintelalwar
    @MrSachintelalwar 10 лет назад

    Thanks, very useful

  • @adarshrauniyar3711
    @adarshrauniyar3711 3 года назад

    can CTE be used for more than 2 tables?

  • @Trzbne
    @Trzbne 6 лет назад

    Dears, how do you make Result and Message tabs disappear?

  • @gkmishra2009
    @gkmishra2009 5 лет назад

    Give video on how consume web api in wcf

  • @mgsprasad22
    @mgsprasad22 4 года назад

    where cte are stored like in database or in tables

  • @mbssupport953
    @mbssupport953 6 лет назад

    Why we use,and where we use...
    And benefits ...

  • @muthukumar-hn9wr
    @muthukumar-hn9wr 10 лет назад

    Is it possible to pass the list(array) as parameter to SQl?

  • @cautioni
    @cautioni 3 года назад

    but totalEMployees isn't a field of tblDepartment, someone please explain

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

      We are taking as alias for total count

  • @vidigyamishra6523
    @vidigyamishra6523 6 лет назад

    why am i getting errors....WITH Employeecount (Departmentid,TotalEmployees) as (SELECT Departmentid, COUNT (*) AS TotalEmployees
    From [dbo].[EMPLOYEE]
    group by Departmentid)
    SELECT DeptName, TotalEmployees
    from [dbo].[DEPARTMENT]
    join Employeecount
    on [dbo].[DEPARTMENT].deptid = [dbo].[EMPLOYEE].Departmentid
    ORDER BY TotalEmployees

    • @venkateshpinapala399
      @venkateshpinapala399 5 лет назад

      In Join Employeecount on [dbo].[DEPARTMENT].deptid = [dbo].[EMPLOYEE].Departmentid,
      after = you used [dbo].[EMPLOYEE].Departmentid where you should use Employeecount.Departmentid

  • @m.s.krishnamurthykitta
    @m.s.krishnamurthykitta Год назад

    I am so unlucky 😔 because it's too late to display in mobile RUclips channel .
    , Now I'm probably Lucky Man because it pop-up on my screen..now ..

  • @dbgaragedays2664
    @dbgaragedays2664 5 лет назад

    Why do you need a cte here..? Why not just do this?
    Select dept.name, count*
    From employees emp
    Join department dept
    On emp.deptid = dept.empid
    Group by dept.name

    • @jigneshvyas3105
      @jigneshvyas3105 3 года назад

      I guess you mean emp.deptid= dept.deptid? The purpose of the tutor ihere is to explain basics of CTE which you can use for more complex queries.