Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
ONLY, as I understand it:
If , (for a given row, dimension, or group) has ONLY one distinct value of {Expression}, return it, else (more than one), return null.
I'm wondering if any flavor of SQL has the equivalent idea?
I think the answer is no, -- there is no direct , "out of the box" equivalent.
However, I think the same can be achieved manually, doing something like this. This is would-be SQL Server syntax -- but I don't know if the syntax is correct, I'm asking the idea in principle.... I'd be curious if any flavor of relational database supported this idea of "ONLY", but we use SQL Server.
SELECT
(CASE WHEN COUNT(DISTINCT Expression)>1 NULL() ELSE MAX(Expression) END) as OnlyExpression
GROUP BY {Dimension}
It's theoretical question and I want a definite answer.
Specifically the business asked me to cross-check that the Qlikview chart (using an ONLY expression) -- which dipped drastically low in recent months -- was correctly calculating the numbers. (Of course it is... but when the business asks...)
I got the numbers in SQL Server to match the numbers in the Qlikview line chart using the SQL (Server?) expression I described in my original question, along with a Common Table Expression (CTE) -- which acted like my Qlikview "Load Script"
This is indeed the equivalent of ONLY:
(CASE WHEN COUNT(DISTINCT Expression)>1 THEN NULL ELSE MAX(Expression) END) as OnlyExpression
Thank you... This is what I guessed and is indeed the same for SQL Server as Oracle Server