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

Constructing a VIEW for Hiding ID with a one to many scenario

Status
Not open for further replies.

vcujackson

Technical User
Apr 7, 2009
18
US
I have a one to many scenario and need assistance
One ID can have many Attributes
if ID has attribute 6025 I want to eliminate that ID in the VIEW or proceedure. Here is a sanpshot
ID Attribute
1233 6025
1233 6033
1233 6034
In this example because ID 1233 has 6025 I want to eliminate the entire ID 1233 not just ID 1233 with attribute 6025. I eventually want to bring this into a report using crystal reports or microsoft report services. Any ideas. Is this a procedure candidate or can this be done with a simple view.
 
SELECT * FROM SomeTable WHERE [ID] NOT IN

(SELECT [ID] FROM SomeTable WHERE Attribute = 6025)
 
How about

Select ID, Attribute
From Tablename
left join(Select ID
From Tablename
Where Attribute=6025
) Att6025
on Att6025.id=Tablename.id
and Att6025.id is null
















 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top