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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to identify records

Status
Not open for further replies.

awise

IS-IT--Management
Dec 11, 2001
85
I need help with a script that will query a table with items (inventory items) and return the results where that item only has one record.

Each item is assigned to a site when entered into our inventory system. Later an item can be assigned to various different sites (locations). Initailly all items are assigned to a master default site "A". Any item will
be assigned to other sites, as needed, when these items are transfered to those site (locations)

Table record ex:

item # Site #

abc A
abc b
xyz A

I want a script that will return the items that only have a site A. The results here would be "xyz"

Appreciate your help.

Thanks,

zaw


 
Here's a starting point...

The query below will return records where the item ONLY appears in 1 record. It doesn't take in to account what the value of the Site column is.

Code:
Select Item, Count(1)
From   Table
Group By Item
Having Count(1) = 1

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top