I've got a SQL script which returns a result set, the requirement is to return a default result set with default values if the below script does not yield any results. It should have the same column names as the below script
-- Return final results
SELECT
p.worked [AccountsWorked],
p.rcmade [RPC's],
p.obtained [PTPCount],
p.amount [PTPValue],
[PreviousDayPTPValue]
FROM
@tab_performance p JOIN
dbo.user usr ON
(p.usr_code = usr.usr_code) JOIN
dbo.team tme ON
(tme.tme_id = usr.tme_id)
AND p.usr_code = @usr_code
I need to return a default result set if no rows are returned. So all the columns should be returned with NULL's or any default value.
I have tried conditional select statements without any luck, I have also tried the @@ROWCOUNT