sql - Inserting dummy values at the end of select -
sql - Inserting dummy values at the end of select -
i have got query returns address , completed orders against each address lastly week. need insert 3 dummy values within result set.
select address ,sum(case when orderdate >= dateadd(dd,(datediff(dd,-53690,getdate()-1)/7)*7,-53690) 1 else 0 end) completed orders grouping address order address
result
address--------------completed
address1----------------3
address2----------------3
address3----------------3
address4----------------3
all values coming database, want insert 3 rows hard coded values
expected result
address--------------completed
address1----------------3
address2----------------3
address3----------------3
address4----------------3
dummy1------------------0
dummy2------------------0
dummy3------------------0
unsuccessful effort
select address ,sum(case when orderdate >= dateadd(dd,(datediff(dd,-53690,getdate()-1)/7)*7,-53690) 1 else 0 end) completed orders union select 'dummy1', 0 grouping address order address
try -
select address ,sum(case when orderdate >= dateadd(dd,(datediff(dd,-53690,getdate()-1)/7)*7,-53690) 1 else 0 end) completed orders union select 'dummy1' address, sum(0) completed grouping address order address
sql sql-server tsql
Comments
Post a Comment