Click here to Skip to main content
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
Shibiny566

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)

  Print Answers RSS
0 OriginalGriff 5,170
1 DamithSL 4,357
2 Maciej Los 3,750
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,851


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 18 Sep 2012
Copyright © CodeProject, 1999-2014
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