QueryBuilder & Formular (NULLIF)

Hello all,

in oldschool sql I have a select with
SELECT COUNT(NULLIF( schedule, \'\' )) AS schedules`

I am migrating everything to QueryBuilder but am not sure about this one.
Its an Alias, Function + Formula

$sql->selectAlias($sql->func()->count('NULLIF( schedule, \'\' )'), 'schedules')

was not successful. when executing, the DB does not recognize the “schedule” as a file in a constellation like this.

any other suggestion?

Sounds like a tricky one. You could try to use \OCP\DB\QueryBuilder\IQueryBuilder::getColumnName for schedule, like $sql->selectAlias($sql->func()->count('NULLIF( ' . $sql->getColumnName('schedule') . '), \'\' )'), 'schedules')

Hi,
thank you for the answer. does not seem so simple

DB-Error is a syntaxerror at schedule
'SELECT \"dataset\", COUNT(\"id\") AS \"dataloads\", COUNT(\"NULLIF( \"schedule\", '' )\") AS \"schedules\" FROM \"oc_analytics_dataload\"

I think the problem is, that whatever is proivded to the func() is treated as a column itself. thats why NULLIF is already framed in “”