【问题标题】:Reporting Services - concatenate string and parameterReporting Services - 连接字符串和参数
【发布时间】:2013-07-03 07:26:46
【问题描述】:

这里的正确查询是什么?

我想将“年份”作为参数:

select distinct
p.id "pub_id"
from 
publication "p", organisation_association "oa", organisation "o", localized_string_text "lst_org"
where
p.id = oa.publication_id
and oa.organisation_id = o.id
and o.name_id = lst_org.localized_string_id
and p.submission_year = ?
and exists (select 1
        from
        publication "p2", organisation_association "oa2", organisation "o2"
        where
        p2.id = p.id
        and p2.id = oa2.publication_id
        and oa2.organisation_id = o2.id
        and o2.period_end_date < date ? + '-01-01')

但是最后一行的连接会产生语法错误。

【问题讨论】:

    标签: postgresql service parameters reporting concatenation


    【解决方案1】:

    如果参数作为年份字符串传递:

    and o2.period_end_date < date (? || '-01-01'))
    

    如果是日期:

    and o2.period_end_date < date_trunc('year', ?)
    

    如果是年份数字:

    and o2.period_end_date < date (?::text || '-01-01'))
    

    【讨论】:

    • 感谢 Clodoaldo Neto!它完美地工作!我一次又一次地被这些论坛的力量所震撼!!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多