Tools & Utilities

turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

03-30-2009
06:11 PM

03-30-2009
06:11 PM

Intersection of a set of queries in a cursor

Hello all,

I am trying to code a cursor/procedure as follows,

I have a set of queries . The queries differ only by a single variable value.

An example would be ..

select * from ABC where X = 'Y' & U = 'V'

select * from ABC where X = 'Y' & U = 'M'

The variable U is a column in another table , which I will join in the cursor.

At the moment my query loosk like ,

select * from ABC where X = 'Y' & U = 'V'

INTERSECT

(

select * from ABC where X = 'Y' & U = 'M'

INTERSECT

(

select * from ABC where X = 'Y' & U = 'N'

)

)

I want to do this intersection 'n' number of times , until all distinct values of the column 'U' have been tested .

For this I plan to use a cursor/ procedure.

However , i am finding it difficult to implement the query .

Any suggestions...

Regards,

az_maverick

I am trying to code a cursor/procedure as follows,

I have a set of queries . The queries differ only by a single variable value.

An example would be ..

select * from ABC where X = 'Y' & U = 'V'

select * from ABC where X = 'Y' & U = 'M'

The variable U is a column in another table , which I will join in the cursor.

At the moment my query loosk like ,

select * from ABC where X = 'Y' & U = 'V'

INTERSECT

(

select * from ABC where X = 'Y' & U = 'M'

INTERSECT

(

select * from ABC where X = 'Y' & U = 'N'

)

)

I want to do this intersection 'n' number of times , until all distinct values of the column 'U' have been tested .

For this I plan to use a cursor/ procedure.

However , i am finding it difficult to implement the query .

Any suggestions...

Regards,

az_maverick