Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NOT IN

Status
Not open for further replies.

aomara

MIS
Nov 18, 2002
48
LY
I am making a report that brings the Non-Moved Items in a store database.
I have the "ITEMS" table include ITEM_CODE column
and Transaction table "TXN_TABLE" includes ITEM_CODE column and TXN_DATE coulmn.

I would like to bring all items from the "ITEMS" table that are not in the "TXN_TABLE" within certain date.

I Try to do this in diffrenent ways, But It fails.
 
depending on your database, I work on a SQL2000

Try something like this

Code:
select * from ITEMS
where ITEMS_ID not in (select distinct ITEM_CODE  from
ITEMS where 
ITEM_CODE   in (select distinct ITEM_CODE from TXN_TABLE
where (TXN_DATE  between convert(datetime, '01/01/2004',103) and convert(datetime, '01/01/2005'))))

Mo
 
What version of CR are you using ?

One way to accomplish this would be to usea subquery i.e.

Code:
SELECT ITEMS.ITEM_CODE
FROM ITEMS CROSS JOIN TXN_TABLE
WHERE (NOT (ITEMS.ITEM_CODE IN 
(SELECT ITEM_CODE FROM TXN_TABLE 
WHERE (TXN_DATE > ?DATE) AND (TXN_DATE < ?DATE))))

post more information about your CR version and database type if you require further help.




Gary Parker
MIS Data Analyst
Manchester, England
 
Many Thanks for your help.

1) My database is SQL.

2)I know how to do it using the SQL.

I want to do this with the Crystal Reports 9.
How to adjust tables and relations in the Database Export to bring this results.

Thank You.
 
Try the earlier suggestions by selecting "Add Command" in the database expert. The query would act as the datasource for your report, or you could link the command to other tables.

-LB
 
Hi,
You can try joining the tables in CR, using the
ITEM_CODE field and make it a Left Outer <> join from
ITEMS to TXN_TABLE..
In the record selection criteria specify the Date needed.

This should return all records where the ITEM_CODE is NOT in the TXN_TABLE...



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top