CoFran
CoFran

Reputation: 5

add a static row to ssrs query

I am wondering if there is a way to add a fixed/ static row to a SSRS query depending if the row exist.

let's say I have the table below:

Header1 | Header2

Value1 | Value2

I would like to know how can I add an additional row called Value under Header1 with Header2 having 0 as value if Header1 does not already contain a row called Value?

PS: I cannot use SQL keyword CONTAINS Thank you.

Upvotes: 0

Views: 269

Answers (1)

Rajesh Bhat
Rajesh Bhat

Reputation: 811

You can use union to include a static row.

if not exists (select 1 from Table where Header1='Value')
BEGIN
select Header1, Header2
From Table
Union
Value as 'Header1',0 as 'Header2'
END

Upvotes: 1

Related Questions