locked
How to use if exists or not RRS feed

  • Question

  • User-797751191 posted

    Hi

      I have below query . I want if select statements have no records then else part should return

    select "Description" as "Nature of Supplies",
    		   BaseSum as "Total Taxable value",
    		   IGSTSum as "Integrated Tax"
    	from 
    	(select 'Supplies made to Unregistered Persons' as "Description",
    		    convert(numeric(19, 2), isnull(sum(BaseSum), 0)) as "BaseSum",
    		    convert(numeric(19, 2), isnull(sum(IGSTSum), 0)) as "IGSTSum",
    		    1 as TabOrder
    	from GST_Report_GSTR3B
    	group by PoS
    	union all
    	select 'Supplies made to Composition Taxable Persons' as "Description",
    		    convert(numeric(19, 2), isnull(sum(BaseSum), 0)) as "BaseSum",
    		    convert(numeric(19, 2), isnull(sum(IGSTSum), 0)) as "IGSTSum",
    		    2 as TabOrder
    	from GST_Report_GSTR3B) t0

    Thanks

    Tuesday, February 11, 2020 2:06 PM

All replies