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 |
|
cr488
Starting Member
23 Posts |
Posted - 2007-07-27 : 15:20:16
|
| There are table A, B, C.A has all data for 2007, B have all the data for 2006. (A and B are the same except date range) C is the table to link to A and B.I only want to pick up data from A if date range between 01/01/2007 to 03/01/2007, otherwise, if date range is 01/01/2006 and 03/31/2006, will only show data from table B. Can you help me on this? Thanks!Select A.*, B.* ; From A, B ; Inner join C on A.id = C.id ; Inner join C on B.id = C.id ; Where (A.date between ‘01/01/2007’ and ‘03/31/2007’) or (B.date between ‘01/01/2006’ and ‘03/31/2006’)This way will show both A and B data.What can I do to only show A data or only show B data? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-07-27 : 15:26:20
|
SELECT *FROM aWHERE Date BETWEEN '01/01/2007' AND '03/31/2007'UNION ALLSELECT *FROM bWHERE Date BETWEEN '01/01/2007' AND '03/31/2007' E 12°55'05.25"N 56°04'39.16" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-07-27 : 16:00:10
|
OrSELECT *FROM aWHERE Date BETWEEN '01/01/2006' AND '03/31/2006'UNION ALLSELECT *FROM bWHERE Date BETWEEN '01/01/2006' AND '03/31/2006' E 12°55'05.25"N 56°04'39.16" |
 |
|
|
cr488
Starting Member
23 Posts |
Posted - 2007-07-27 : 16:11:52
|
| Thanks a lot for the help. |
 |
|
|
|
|
|