Advanced SQL Tutorial

Поделиться
HTML-код
  • Опубликовано: 20 окт 2019
  • In this tutorial I will cover many advanced SQL concepts like full outer joins, coalesce, cross apply, outer apply, intersect, except and pivot.
    NOTE: The database I use for this tutorial is MS SQL Server and the syntax can vary depending on the database.

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

  • @kamlist2808
    @kamlist2808 3 года назад +7

    What a legen! His restaurants went bankrupt but now he teaches us SQL. Thank you Jamie Oliver

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

    I find your vids real helpful as a full stack dev tweaking sprocs every now and then. Thanks for the content.

  • @IanJohnstonblog
    @IanJohnstonblog 3 года назад +3

    Great Video. Thanks for making your series on SQL... I've learned a ton from your clear and concise explanations.

  • @zackjones8681
    @zackjones8681 4 года назад +8

    Thanks for this. I finally have PIVOT working! I've converted two stored procedures so far and will be converting more now that I understand how it works.

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

    >Thanks for watching
    Thanks for creating

  • @shreyapansari5114
    @shreyapansari5114 4 года назад +5

    Amazing ! finally could understand coalesce and pivot. Please make videos on stored procedures, CTE and materialised views.

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

    Great vid! Difficult topics explained in a very clear and easy way to understand! Thanks and keep them coming!

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

      Thank you so much! Will do! :)

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

    Loved the video!!! thank you for making this amazing video.

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

    Thank you! I was looking for the SQL equivalent of the || operator, and had read about coalesce before. Your video really made it "click" for me.

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

      Always like to know I'm helping people. That is what it is all about.

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

    This is super useful stuff , thanks a lot mate

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

    Brilliant! Well done!

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

    Thank you! Great video!

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

    Man you just rock thank you for sharing ❤

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

    appreciate the vid brother

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

    Great video!

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

    loved it :)

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

    Nice breakdown of pivot table

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

    Thanks bro... Amazing video

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

    Nice!!

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

    Thank you

  • @FirstNameLastName-kt3zn
    @FirstNameLastName-kt3zn 4 года назад

    This was a helpful explanation of PIVOT

  • @waltherziemerink
    @waltherziemerink 4 года назад +1

    Excellent tutorial

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

      Neo-1 I appreciate the kind words

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

    Great video.

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

    Thx

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

    so at @2:10 you want to only select specific columns that they asked for which was the ecom quantity and store quantity don't need to see the color and all that

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

    Great videos. Thank you. Only if you can control those juicy tong sounds.

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

    Thanks for the video. Can you please make a video on how Enterprise manager reports can be leveraged.

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

      Great suggestion! I will put that on my list.

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

    @3:17 is there a is not null for the product id or is that a different concept?

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

    SQL is supposed to be simple human readable. Always had issues with the Pivot, the fact that the Categories values had to be hard-coded in the code makes it static. There are solutions on the internet how to first read the list of categories values in a variable.

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

    If I had u as my datasci professor I couldve been working at IBM by now

  • @Stelios.Posantzis
    @Stelios.Posantzis 4 года назад

    Neat and concise. Great for familiarizing oneself with these features. If it included the UNPIVOT statement it would a make for a nice, complete tutorial.

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

    Hi, We may also use Isnull(s.ProductID, e.ProductID) ProductID instead of coalesce this gives also same output. plz verify.

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

    So what's the value in using OuterApply or CrossApply? Based on the demo, the result could be achieved with Table Joins. Anyway, I can Google for the answer. Was always curious when to use Cross Apply or Outer Apply, never knew the answer until this came up in a job interview.

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

    Will I be able to apply this on mysql??

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

    Cool, i have a doubt. Suppose i have a table with 3 columns say name,id,address and say 100 records. The table has some of the values in name,address filled with null or blank space. I Need to take report which shows me the count of records with blank spaces,null and this shud be achieved without using group by

  • @user-fx3cs7ew1o
    @user-fx3cs7ew1o 6 месяцев назад

    at the first query, isn't it the same as union all? instead of left join+coalesce? if not, when do you use which?

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

    Not sure if you will ever respond but.. why you didn't used the alias for ProductId in the COUNT function?

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

    Why can't we just go for a simple subquery for the 1st requirement , Select * from table1 t1 where t1.id in (select id from table2)

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

    how can you import csv file to an already existing table using sql query?
    like suppose you have Customer table and now you want to add data from xyz.csv file and both Customer and csv file have same attribute ,then how to do such task?

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

    hi your advanced sql session is really helpful...could you please upload some more advanced queries?

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

      ADITYA ANAND sure will do

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

      Thanks a lot....I am working on data analysis and i have to use sql with advance functions for transformations etc and so I thought that u could help me....thanks ...

  • @AnshulMarele-gbaa
    @AnshulMarele-gbaa Год назад

    How to enable viewing syntax and command definition [while typing any command] in MS-SQL as we see in Excel

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

    In the pivot statement, would it have been possible to select distinct values rather than listing them?

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

      You need to reference the actual column names. A select returns the values. Unless I'm misunderstanding the question.

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

      @@JamesOliver i guess he meant making a subquery with (select distinct(c.name or category) from productcategory). can we do that in here?

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

    Can you prepare basic to advanced series, so every one can learn SQL

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

    how can i find to this database?

  • @darrylw99
    @darrylw99 2 дня назад

    It's rubbish that you have to hard code the columns for the pivot... can you not do a select Distinct to populate that?

  • @user-ti7zu7wz5e
    @user-ti7zu7wz5e Год назад +1

    It would be hella cool if you add timestamps

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

    Hello Mr. Oliver!
    Could you take a doubt please?
    Regarding the part of the query before the pivot?
    I'm using the same base as you and your query, I achieved exactly the same results that you showed in the video.
    select c.name Category,
    count (p.productid) totalproducts
    from production.product p
    inner join production.productcategory c
    on c.productcategoryid = p.productsubcategoryid
    group by c.name
    go
    Accessories 8
    Bikes 32
    Clothing 22
    Components 43
    It's a simple query like you said then I tried to take the test and I couldn't reach the number that the query arrived
    I'll take as an example the accessories category (productcategoryid = 4) that gave a total of 8:
    select * from Production.ProductSubcategory
    where ProductCategoryID = 4
    go
    productsubcategoryid productcategoryid
    26 4
    27 4
    28 4
    29 4
    30 4
    31 4
    32 4
    33 4
    34 4
    35 4
    36 4
    37 4
    Ok, after this result I did this search:
    select
    count(productid) count_products_cat_accessories from Production.Product
    where ProductSubcategoryID between 26 and 37
    count_products_cat_accessories
    29
    If possible, can you show me why I didn't get the result of 8?
    Thank you!!

    • @JamesOliver
      @JamesOliver  4 года назад +1

      I would have to go back and check but I use this database for other demos/purposes and it is possible I have modified the underlying tables. It has been a little while so would have to check to be sure but that is my guess. Thanks for watching.

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

      @@JamesOliver I thank you! Your videos helped me a lot, they are very didactic!
      Ok, I understood what you said about the db but
      in this case, your query returned exactly the same results as the categories shown in your video.
      I believe that the bases are hitting.
      In the future, if you go back to the original DB AdventureWorks2012, I would appreciate it if you can check where I went wrong. Follow the test print link.
      drive.google.com/file/d/1In0tEldKrakm8YM01qRo_5n5T1or1jXR/view?usp=sharing
      My best regards
      !

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

    what application are you using sir ?

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

      Sql server express and management studio. All free.

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

    @2:45 I guess they don't like to see nulls in their data?

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

      Yea just quickly handling the NULLs and converting to zero

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

    How are you.

  • @50tigres79
    @50tigres79 2 года назад

    should be titled TSQL

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

    How un earth is this considered advanced

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

    lost me @4:30 what is this "function"

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

      Ayejax just a function that returns rows