CASE
WHEN @vessel_certificate_id IS NULL
THEN SELECT
id, name as file_name,
SUM(DATALENGTH(data)) / 1048576.0 AS file_size,
dbo.fn_format_datetime(created_on) as file_date
FROM
vessel_cert_attachment
GROUP BY
id, name, type, created_by, created_on
ELSE
SELECT
id, name as file_name,
SUM(DATALENGTH(data)) / 1048576.0 AS file_size ,
dbo.fn_format_datetime(created_on) as file_date
FROM
vessel_cert_attachment
WHERE
vessel_certificate_id = @vessel_certificate_id
GROUP BY
id, name, type, created_by, created_on
如果param不为null,基于上面的SQL,我希望它执行没有param的select语句,如果有param传递,我希望它执行带where where条件的select语句。
可以这样执行吗?
答案 0 :(得分:0)
在Ubuntu Server
子句
OR
条件
Where