Author: way0utwest

  • I Need a CS Degree. I Don’t Need a CS Degree

    For a long time I’ve felt that my recommendation for people wanting to enter technology wasn’t to go to college and get a degree, but rather start to learn on your own and get an entry level job (help desk, tech support, etc.) and start to work in the industry. That’s a good way to both experiment and understand what you’re considering undertaking as a career, as well as limiting your investment. It’s also nice to get paid to learn something.

    College is great, but it’s also expensive. I find that for many people, it can be hard to get a good ROI from college these days. The fast rising cost, not to mention the uncertain opportunities after college lead me not to recommend pursuing a CS degree, or really any degree, as a default view. There are exceptions, but for many people, I’d prefer to work and try to better understand where they should invest in education.

    However.

    Jerry Nixon has a great (long) post on Twitter on this topic, answering the question of whether someone should get a degree or not, mostly focused on developers and CS degrees. It’s a very nuanced view that you both should and shouldn’t get a degree. It really depends on what you want to do. There are cases where we might want someone to get a degree and deeply understand complex development. It’s one thing to build internal web apps or design a database used by internal sales teams. It’s quite another to design encryption for a military application or ensure a rocket can land on a floating platform.

    Both things can be true together. You should get a degree to be a developer and you should not get a degree to be a developer, but the more detailed answer depends on where you want to work and what you want to achieve. A nice optimistic view from Jerry is that some people want to achieve something bigger than a paycheck, bettering the world with software, not to earn more, but to make life better in some way. I wish more people felt that way.

    A great piece of advice from Jerry is to listen to those who you want to become, not the loudest people. I somewhat lament that so many of the very, very smart people I know or hear about are focused on tooling that generates revenue or income, and not necessarily pursuing improvements in the world. That’s their choice, and I can’t get upset about so many extremely capable technologists working in finance or FAANG rather than areas where they might change the world for the better. I can be though, and am, sad.

    Read the post, and think deeply about what this means to you. And if you want to be a great software or database engineer, then do great things. Work hard at your craft and constantly sharpen your saw.

    Steve Jones

    Listen to the podcast at Libsyn, Spotify, or iTunes.

    Note, podcasts are only available for a limited time online.

  • 2024 PASS Data Community Summit Prep

    Next week is the 2024 PASS Data Community Summit in Seattle. I’ll be traveling Monday to the event to see a few thousand fellow data professionals, developers, managers, and more. I expect quite a few people to be traveling this weekend and enjoying SQL Saturday Oregon and SW Washington or just getting to Seattle for Pre-cons on Monday, but I’m slightly worn out so shortening my trip a bit.

    First Timers

    If you’ve never been to the Summit before (this is the 26th), then there is an FAQ available. I would highly recommend checking out Edwin Sarmiento’s First Timer Guide. It’s a great resource.

    Also, make sure you aren’t this guy (or girl).

    Summit Sessions

    There are a lot of sessions available. I got asked for recommendations, and it was almost overwhelming, even when I skipped pre-cons. All the pre-cons are by great speakers and experts, so no recommendations there. I’m also not recommending lightning talks as those are just for fun.

    Here are some I like, though I am biased towards DevOps and forward-thinking topics.

    There are lots more sessions, but those are ones I’d want to see (or watch later).

    After Hours

    Don’t go out alone. I know some of you need a break or need to re-charge. Heck, I do at times, but minimize this at the Summit. Take advantage of the time to meet others and spend time with them. Build bonds, network, learn more about our industry or just about other people.

    There are community events during and at night. Go on a walk with others, pick a place for dinner on Mon/Tue/Thur/Fri, or ask people to do something in Seattle. I’m not a big nightlife person, so don’t ask me, but I do recommend the Underground Tour if you’ve never done it. There are great museums around if you have an off day, especially the Museum of Flight.

    I’ll be at the SQL Server Central / Datavail Casino Party Tuesday night and the Redgate event Thursday. Wednesday I’ll be at the expo hall reception and then likely go to bed. Dinner with a friend planned for Monday already.

    Enjoy the Summit if you’re there. If you’re not, take my advice above at any event and don’t be an introvert for a few days. You’ll be tired, but you will grow from the experience.

  • A New Word: Bye-over

    bye-over – n.  the sheepish casual vibe between two people who’ve shred an emotional farewell but then unexpectedly have a little extra time together, wordlessly agreeing to pretend that they’ve already moved on.

    I used to feel a bye-over was very awkward. I’d said goodbye, they had, and we’re delayed. I think the advent of Uber and similar services, where we wait more often on trips, has made it easier to say goodbye and then walk away a few steps to wait.

    However, I would also say I’ve just learned to keep chatting with someone if there’s some delay, or even just come back and chat with others.

    From the Dictionary of Obscure Sorrows

  • Counting Groups with Window Functions: #SQLNewBlogger

    I looked at row_number() in a previous post. Now I want to build on that and do some counting of rows with COUNT() and the OVER clause. I’ll show how this differs a bit from a normal aggregate.

    Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers. This is also part of a series on Window Functions.

    The Raw Data

    Let’s use AdventureWorks as a sample database. In the Sales.SalesOrderHeader table there are lots of customer orders, each with a Customer ID. I’ll limit my results to these customers, which has a spread of orders:

    WHERE soh.CustomerID IN (11011, 11015, 11019, 11012)

    We’ll use this WHERE clause to help us decide

    Counting Orders

    If I wanted to count the number of orders each customer hasplaced, I can use this code:

    SELECT
       soh.CustomerID
    , COUNT (*) AS OrderCount
    FROM Sales.SalesOrderHeader AS soh
    WHERE
       soh.CustomerID IN ( 11011, 11015, 11019, 11012 )
    GROUP BY soh.CustomerID;

    I see these results:

    2024-10_0175

    We can see that each of these customers has different numbers of orders.  If I want a simple summary, this is the best code. However, what if I want to add other columns?

    Supposed I want to add not only the customer ID, but also the shipdate. I’m wondering when orders were shipped. If I use the code above, I’d need to add this in the column list, and the group by. If I do this, I get this code:

    SELECT
       soh.CustomerID
    , soh.ShipDate
    , COUNT (*) AS OrderCount
    FROM Sales.SalesOrderHeader AS soh
    WHERE
       soh.CustomerID IN ( 11011, 11015, 11019, 11012 )
    GROUP BY
       soh.CustomerID
    , soh.ShipDate;

    And this result:

    2024-10_0176

    The results are cut off, but they repeat with a 1 for each row. The front end can sum these, but it’s easy to make a mistake here. Especially if there are filters.

    With an OVER() clause, my aggregate changes a bit. I would use this code, where I am paritioning, or essentially grouping, the data by the customer ID. I don’t have a group by, so I don’t need to add other fields in two places. Here is the code:

    SELECT
       soh.CustomerID
    , soh.ShipDate
    , COUNT (*) OVER (PARTITION BY soh.CustomerID) AS OrderCount
    FROM Sales.SalesOrderHeader AS soh
    WHERE
       soh.CustomerID IN ( 11011, 11015, 11019, 11012 );

    And the results.

    2024-10_0177

    I have the count repeated, but if I am showing this in the front end, I can hide that column in a table, but I can also access the total count from any row.

    Differences with Group By

    Let’s say I decide to add something else, like the account number and the SalesOrderNumber. If I do this in a GROUP BY, I need to add this to the column list and the group by, as shown here:

    SELECT
       soh.CustomerID
    , soh.AccountNumber
    , soh.SalesOrderNumber
    , soh.ShipDate
    , COUNT (*) AS OrderCount
    FROM Sales.SalesOrderHeader AS soh
    WHERE
       soh.CustomerID IN ( 11011, 11015, 11019, 11012 )
    GROUP BY
       soh.CustomerID
    , soh.ShipDate
    , soh.AccountNumber
    , soh.SalesOrderNumber;
    GO

    The change the Window function is as shown:

    SELECT
       soh.CustomerID
    , soh.AccountNumber
    , soh.SalesOrderNumber
    , soh.ShipDate
    , COUNT (*) OVER (PARTITION BY soh.CustomerID) AS OrderCount
    FROM Sales.SalesOrderHeader AS soh
    WHERE
       soh.CustomerID IN ( 11011, 11015, 11019, 11012 );

    Maintenance is easy, and what’s more, I don’t have to worry about ordering my group by in different ways. If I do care about grouping, then I can alter the partitioning, but often I just want to add other columns without making the code more complex in a second place.

    The results for the group by have the fields, but all 1s in the count again.

    2024-10_0179

    The window function has the counts for each customer.

    2024-10_0178

    Small things, but those points of maintenance can be annoying and they can cause problems. For complex data, the other fields might not group well, or the order of grouping might change what is shown.

    There are more things to be concerned about here, but one of the big things might be a running total, where I count the orders over time. I’d like results like this:

    2024-10_0180

    My window function code is:

    SELECT
       soh.CustomerID
    , soh.AccountNumber
    , soh.SalesOrderNumber
    , soh.ShipDate
    , COUNT (*) OVER (PARTITION BY soh.CustomerID ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS OrderCount
    FROM Sales.SalesOrderHeader AS soh
    WHERE
       soh.CustomerID IN ( 11011, 11015, 11019, 11012 );

    The regular code with group by is this:

    select soh1.customerid, soh1.AccountNumber, soh1.SalesOrderNumber, soh1.ShipDate
    , count(*) 'running_total'
    from sales.salesorderheader soh1
    inner join sales.salesorderheader soh2 on soh2.salesorderid <= soh1.salesorderid
                                        and soh2.customerid = soh1.customerid
    group by soh1.customerid, soh1.AccountNumber, soh1.SalesOrderNumber, soh1.ShipDate
    order by soh1.customerid, soh1.ShipDate

    Not bad, but the big difference is in resources used. The statistics IO below shows the difference. Can you guess which is which?

    2024-10_0183

    Hint, the one using less reads is the OVER() code.

    SQL New Blogger

    Setting up a good scenario is a little tricky, and that took time. I messed with a few data sets that helped explain this to me, and you, in a way that made sense. I have a few other scenarios, which I will write about because an OVER() isn’t magic and it might not be the right choice.

    Those will be other blogs.

    This is a good way to showcase that you understand part of how this works. There’s a whole series to be written on different aspects of how the OVER() clause works. Spending 15-30 minutes each time you experiment helps showcase your knowledge and learning to employers.

    That’s what employers need: experimenting and learning.