Best way to understand Querying much better

  • What's the best way to get better at T-SQL Querying? Something like

    1. Read/do the Stairways to T-SQL, Indexing
    2. Read Itzik Ben-Gan's book on TSQL Querying
    3. Read Grant Fritchey's book on Execution Plans
    4. Maybe get an account on leetcode.com and do the query challenges?

    Did I leave anything out?  I think Wide World Importers is big enough so that sloppy queries should be obvious?

    Thanks!

  • Blogs!!!!!! for me Brent Ozar's is top

    PodCasts - Data Exposed is good but is more for Azure than T-SQL

    Most importantly - Practice - Get a free copy of SQL 2019 Developer and try (using one of the sample db's or better still make your own db). Set up some sample problems and try to solve them with the best query you can.

    For example, write some code that outputs the numbers 1 to 100, but if the number is dividable by 3 write fizz, if by 5 then pop, if by both fizz pop.

    1,2,fizz,4,pop,fizz,7,8,fizz,10,11,fizz,13,14,fizzpop

  • Thanks... I think I'm going to read Itzik's book and watch some of Kendra Little's T-SQL courses on indexing and querying.

    (Good time to have a normal job where people come every day and ask me questions about their data... Yeah, I remember that from a long time ago!)

    Think I got it...

    --- step 2: calculate fizz, bang, boom.
    --- step 1: generate numbers 1 to 105.
    SELECT num
    , fbb = LTRIM(CONCAT(iif(num % 3 = 0, 'fizz','')
    , iif(num % 5 = 0, ' bang','')
    , iif(num % 7 = 0, ' boom','')
    )
    )
    FROM
    (SELECT TOP 110 num = ROW_NUMBER() OVER (ORDER BY object_id)
    FROM Sys.all_objects ao) nums;

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply