Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
karrojo
Starting Member
26 Posts |
Posted - 2011-05-11 : 00:22:07
|
| Good Day!i really need all your helpi have a query, getting results using three tables. 1. MasterTable 2. ChecksTable 3. SuppChecksTablehowever, i have the ff conditions 1. That in ChecksTable, i only get the checks issued on 2009 and compute the sum of amount 2. In SuppChecksTable, only checks issued in 2009.i got the result that i expected, however if a record in SuppChecksTable has check issued in 2009 and other year, it gives 2 results: (1) the checks issued in 2009 and (2) the checks issued in previous yearsi want to eliminate the result the checks are issued the previous yearshere is my query:select distinct a.col1, a.col2, a.col3, sum(b.Amt), 'SuppPay' = case when (printed between '01/01/2009' and '01/01/2010') then c.col4 else '--' end, 'Amount' = case when (printed between '01/01/2009' and '01/01/2010') then c.col5 else '--' end, 'Date_Printed' = case when (printed between '01/01/2009' and '01/01/2010') then c.col6 else '--' endfrom MasterTable as a inner join ChecksTable as b on a.col1 = b.col1 inner join SuppChecksTable as c on a.col1 = c.col1where (b.date between '01/01/2009' and '01/01/2010')group by a.col1, a.col2, a.col3your comments and suggestions will greatly help. thanks so much |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
|
|
|
|
|