Friday 15 June 2012

sql server - Implement two filters in one condition - SQL -


I am creating a report in which I am not showing total clue, sent through fax and via SMS Is sent from I wrote a procedure to get the record. Here I will have to check a situation which should not be zero zero sales sent by fax and fax sent through SMS. If both are zero then I should not be brought to the record. If any of them have any value then I should get the record. It is possible to apply it through the SQL query.

astander the OP note

  Select as C.ClientID, C.ClientName, C.OrganizationName, C.FirstName, S SMSOverageRate, '' cost add calculated as TotalLeads (*), (case DeliveryViaFax when 'Y' is 1 and 0 at the end) of FaxCount, as the amount (in case DeliveryViaSMSEmail when 'Y' is 1 and 0 end) CMN_LeadSaleDetails s as SMSCOUNT Where join insider CMN_LeadClients C.ClientID = C S.BuyerID C.SellerTenantId = @TenantId and S.SellerJournalID = case @JournalId when 0 then S.SellerJournalID otherwise @JournalId end group C.ClientID, C.ClientName, C.OrganizationName By, C. .FirstName, SSM OverRate  
< / Div>

You can try something like this

 from  select from * table ( Total SMS Lide! = 0 or Total Fax Lids! = 0)  

Provide an easy-to-query query and we can further assist you.

Well, the comment you made, I will try to do something like this

  SELECT C.ClientID, C.ClientName, C.OrganizationName, C.FirstName, as S.SMSOverageRate, '' costs, as TotalLeads, count (*) add (case DeliveryViaFax when 'Y' is 1 and 0 end) FaxCount, add (case 'Y' when as DeliveryViaSMSEmail 1 0 end) where C.ClientID = on C consists of internal CMN_LeadClients CMN_LeadSaleDetails from SMSCOUNT S.BuyerID C.SellerTenantId = @TenantId and S.SellerJournalID = case @JournalId by C.ClientID when 0 then S.SellerJournalID otherwise @JournalId end Group, C.ClientName, C.OrganizationName, C.FirstName, S.SMS Having OverageRate (Addition (Case DeliveryViaFax when 'Y' then 1 and 0 End)! = 0 or Add (case DeliveryViaSMSEmail when 'Y' then 1 and 0 End)! = 0)  

No comments:

Post a Comment