The concept here is that a NULL and a '' are to be shown as '[BLANK]' (the literal text that is).
I now have a similar query, where, rather than a single table, the sort is coming from 6 different tables.
So, convention says ...
COALESCE ( CASE SL_1.CUSORT WHEN '' THEN NULL END, CASE SL_2.CUSORT WHEN '' THEN NULL END, CASE SL_3.CUSORT WHEN '' THEN NULL END, CASE SL_4.CUSORT WHEN '' THEN NULL END, CASE SL_5.CUSORT WHEN '' THEN NULL END, CASE SL_6.CUSORT WHEN '' THEN NULL END, '[BLANK]' ) [S/L Sort],
One I have is to replace the FROM <tablename> with FROM (SELECT case when ...) tablename. But the query is already 614 lines long and whilst I can certainly do this, is there a shortcut I'm missing?
OOI. The massive query aggregates data from 30 tables over 13 different databases on 2 different SQL servers.
Microsoft SQL Server 2005Microsoft SQL Server 2008SQL