MAX/MIN, Scalar vs Aggregate function and NULLs #db2fori #ibmi

This is a note on a surprising difference and kind of a follow-up on a RPGPGM.COM article (so go read it first and put the site in your favorite!). I already commented on it there, but thought it would be worth a small post. Try to guess the result for the following statement, then letContinue reading “MAX/MIN, Scalar vs Aggregate function and NULLs #db2fori #ibmi”

a CONCAT_WS-like on #db2fori #ibmi

In July, I left a position as a data manager on SQL Server (and a bit of MySQL) to start as a database developer on… Db2 … for i. I’m now going through a paradigm shift and transfer some knowledge to the platform. I had a use case for ‘CONCAT_WS‘. Concatenate 0, 1 or moreContinue reading “a CONCAT_WS-like on #db2fori #ibmi”

Multi-Column “Aggregation” MAX(), MIN(), COUNT() & Co with #SQLServer

It’s amazing to see how Microsoft keep on improving T-SQL. I was happily surprised to hear that GREATEST and LEAST are comming to Azure SQL Database from Version 2016 on… however only on Azure SQL. I’m currently ‘stuck’ with SqlServer 2017 on Premise (at least it is not any out of support version, like 2008R2)Continue reading “Multi-Column “Aggregation” MAX(), MIN(), COUNT() & Co with #SQLServer”

IDENTITY crisis — 4. IDENTITY-free #SQL programming

In Part 1 and Part 2, I set the background. In Part 3, I attacked a castle… it is now an infested ruins. We’re now building a better version of it (meeting the specification). Our new castle with relational fortifications. Who told database design is no fun? The environment I’m using a full fledged MicrosoftContinue reading “IDENTITY crisis — 4. IDENTITY-free #SQL programming”

IDENTITY crisis — 3. Relational Distancing

After Part 1 and Part 2. I want to embark on a code review. Playing the pathologist, running a small diagnostic on the diagnose table and its friends. Relationaaaaaaah By the all mighty, we shall invoke SchemaSpy, and the picture should speak: I now feel so sad for diagnose. Quarantine measures? The only relation isContinue reading “IDENTITY crisis — 3. Relational Distancing”

IDENTITY crisis — Part 1: a DISTINCT in disguise

Nothing looks more alike than 2 INT. I wish a warning could come if I ever try to join on 2 columns defined with IDENTITY. This started as a single post. But as I’m redacting, it gets longer. I plan/need to split it in 3 parts. That being said: If you want to make GodContinue reading “IDENTITY crisis — Part 1: a DISTINCT in disguise”

string_agg() does not max alone — #SQLServer #SQLNewBlogger

… and that surely is for good reason when you check how the nvarchar(max)/varchar(max) family is treated. As I moved from PostgreSQL to SQL Server 2008R2 one of the things I missed the most were all the out of the box aggregation functions. And one of them was string_agg(). We migrated last year from 2008R2Continue reading “string_agg() does not max alone — #SQLServer #SQLNewBlogger”

IDENTITY crisis — 2. Death by Surrogate

Nothing looks more alike than 2 INT. I wish a warning could come if I ever try to join on 2 columns defined with IDENTITY. Surrogate: 1 – Developer: 0 We left with … on v.id = c.id … and the query was: In our database on v.id = c.id should be something strange, createContinue reading “IDENTITY crisis — 2. Death by Surrogate”

Trigger the ORM

I’m not that a fan of ORM. Surely because I also don’t have to program with OOP language (C#, Java…). From the experience so far, it has mostly been a fight more than a cooperation. To be honest it may play well with the database but the software design decision are trickling down to theContinue reading “Trigger the ORM”