[Qgis-user] New Labeling: conditional labels
Martin Dobias
wonder.sk at gmail.com
Fri Jan 6 04:25:46 PST 2012
Hi
On Thu, Dec 29, 2011 at 11:33 AM, Nathan Woodrow <madmanwoo at gmail.com> wrote:
> It would be handy to add condition statements to QgsExpression so we can
> support this kind of thing, Martin would be the guy to talk to about adding
> this kind of thing. He knows the most about QgsExpression.
SQL recognizes CASE statement with following alternate syntax:
1. "if" equivalent:
CASE
WHEN x > 10 THEN 'big' ELSE 'small'
END
2. "switch" equivalent:
CASE x
WHEN 5 THEN 'five'
WHEN 6 THEN 'six'
ELSE 'something else'
END
The "else" is not required, if there is no matching "when" then NULL
is returned.
Some SQL engines add further functions for convenience:
- MySQL [1]: IF(), IFNULL(), NULLIF()
- PostgreSQL [2]: COALESCE(), NULLIF()
I would suggest to implement the CASE statement to stay compliant with
SQL syntax (although I find It a bit verbose).
Regards
Martin
[1] http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html
[2] http://www.postgresql.org/docs/8.1/static/functions-conditional.html
More information about the Qgis-user
mailing list