Sunday, June 1, 2014

Need multiple Condition in Where Clause

Are you looking for the below?



CREATE TABLE LedgerTable (Particulars varchar(200),Debit decimal(18,3), Credit decimal(18,3), Category varchar(200));
INSERT into LedgerTable (Particulars, Debit, Credit, Category) values
('Asset', 0,80, 'Class'), ('CASH1', 0,100, 'Control'),('CASH2', 0.0,0, 'Control'),('Fittings', 20,0, 'Control'),('Furniture', 0,0, 'Control')


Declare @suppressZero int = 1
Select * From LedgerTable

Select * From LedgerTable Where (@suppressZero =1 and Debit + Credit >0) OR (@suppressZero=0)

Drop table LedgerTable


No comments:

Post a Comment