Click here to Skip to main content
11,481,843 members (62,177 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET
How to combain two select query with multiple conditions in asp.net c#
my query
:

Query1:
..........

SELECT
           dbo.MemberTransactionMaster.YearID,
           Month(dbo.MemberTransactionDetails.VoucherDate)as TMonth,
           SUM(dbo.MemberTransactionDetails.Credit)
FROM       dbo.MemberTransactionMaster INNER JOIN
dbo.MemberTransactionDetails ON dbo.MemberTransactionMaster.TransactionMasterID = dbo.MemberTransactionDetails.TransactionMasterID
WHERE dbo.MemberTransactionDetails.VoucherType='WC'
GROUP BY dbo.MemberTransactionMaster.YearID,Month(dbo.MemberTransactionDetails.VoucherDate)
Order by dbo.MemberTransactionMaster.YearID,Month(dbo.MemberTransactionDetails.VoucherDate)



Query2:
...............
SELECT  SUM(dbo.MemberTransactionDetails.Debit)
FROM    dbo.MemberTransactionMaster INNER JOIN
dbo.MemberTransactionDetails ON dbo.MemberTransactionMaster.TransactionMasterID = dbo.MemberTransactionDetails.TransactionMasterID
WHERE dbo.MemberTransactionDetails.VoucherType='WW'


Any one please help me..........
Posted 18-Sep-12 1:07am
Shibiny564

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

hi,

you can use In clause like
VoucherType in ('WW','WC')
instead of using two separate commands.
  Permalink  
v2
Comments
Shibiny at 18-Sep-12 6:59am
   
but each one have different conditions
Abhijit Parab at 18-Sep-12 7:24am
   
Hi Shibiny,
Can you please give me the format of the output. So it will be easy to form a query.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.150520.1 | Last Updated 18 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100