Hi @Navinkumar Kanagaraj
You can try this:
declare @hasappleororange int
declare @hasnovalue int
set @hasnovalue =(select count(*)from TABLEC)
if(@hasnovalue=0)
begin
select NAME= null
end
else
begin
set @hasappleororange =(select count(*)from TABLEC where NAME in('APPLE','ORANGE'))
if (@hasappleororange>=1)
SELECT distinct NAME from TABLEC where NAME in('APPLE','ORANGE')
else
SELECT * FROM (VALUES('GRAPE'),('KIWI')) AS p(NAME)
end
when there is no data, result is:
Best Regards,
Isabella
If the answer is the right solution, please click "Accept Answer" and upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.