select
n.notification_uid
n.notification
n.descr
n.descr
to_char(s.dt_show_from, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_show_from
to_char(s.dt_show_to, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_show_to
to_char(s.dt_created, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_created
to_char(s.dt_updated, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_updated
from notification n
where 1=1
AND (n.dt_show_from <= CURRENT_TIMESTAMP OR n.dt_show_from IS NULL)
AND (n.dt_show_to >= CURRENT_TIMESTAMP OR n.dt_show_to IS NULL)
AND (n.companyId = OR n.companyId IS NULL)
order by dt_show_from desc
limit #maxrows#
select count(*) as cnt
from notification n
where 1=1
AND (n.dt_show_from <= CURRENT_TIMESTAMP OR n.dt_show_from IS NULL)
AND (n.dt_show_to >= CURRENT_TIMESTAMP OR n.dt_show_to IS NULL)
AND (n.companyId = OR n.companyId IS NULL)
order by dt_show_from desc