Click here to Skip to main content
11,647,659 members (57,855 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 0:07am
Shibiny571

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 jyo.net 500
1 F-ES Sitecore 410
2 OriginalGriff 322
3 DamithSL 315
4 CPallini 250
0 OriginalGriff 1,342
1 jyo.net 994
2 DamithSL 971
3 Sergey Alexandrovich Kryukov 873
4 CPallini 795


Advertise | Privacy | Mobile
Web02 | 2.8.150804.3 | 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