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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2007-03-12 : 09:25:05
|
| Judy writes "I have created a table and do not want the matching records of the created table in the results.SELECT PONUMBER, POPRCTNMINTO ##USETAXFROM POP10500WHERE DateRECD between '2007-02-01' and '2007-02-28'ANDITEMNMBR like '%TAX%'But my results give me the matching records.When I run the query on the first table where the date range is between I get 1061 recordsSelect * from Pop10500 where DateRECD between '2007-02-01' and '2007-02-28'When I run the second query with the join I get 754 records (Records which match the second table)Select a.PONUMBER, a.POPRCTNM, a.ITEMNMBR, a.vendorid, a.orcptcost from Pop10500 a JOin ##USETAX b on a.PONUMBER = b.PONUMBER AND a.POPRCTNM = b.POPRCTNM where a.DateRECD between '2007-02-01' and '2007-02-28'order by a.PONUMBERSo, I want the results to be 303 records " |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-12 : 10:11:13
|
| [code]Select a.PONUMBER, a.POPRCTNM, a.ITEMNMBR, a.vendorid, a.orcptcost from Pop10500 a LEFT JOin ##USETAX b on a.PONUMBER = b.PONUMBER AND a.POPRCTNM = b.POPRCTNMwhere a.DateRECD between '2007-02-01' and '2007-02-28' and b.PONUMBER IS NULL and b.POPRCTNM IS NULLorder by a.PONUMBER[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
JudyV
Starting Member
1 Post |
Posted - 2007-03-14 : 15:59:55
|
| Thank you for your help. Guess, I was having a brain burp. |
 |
|
|
|
|
|