11 Replies Latest reply: Jan 11, 2016 3:31 AM by Nathaniel Anderson RSS

    Does any SQL have the idea of "ONLY"?

    Nathaniel Anderson

      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.



      (CASE WHEN COUNT(DISTINCT Expression)>1 NULL() ELSE MAX(Expression) END) as OnlyExpression

      GROUP BY {Dimension}