USING DYNAMIC LIST

Hello
Is it possible to use dynamic list when using where  in (
example..........

select t1.* from mytable t1
where t1.id in (select id from mytable2)

if so then how

Regards
philsivyerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sdstuberCommented:
your example exactly correct

if it's not working what error do you get?
0
Swadhin Ray Commented:
Check this link hope you will get solution for what you are looking for  :

http://www.oracle-base.com/articles/misc/DynamicInLists.php
0
philsivyerAuthor Commented:
Sorry
Should have been more specific -

using oracle pivot function as per

pivot
(
   SUM(Amount)
   FOR ID IN (SELECT  ID FROM MYTABLE2)
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

ThommyCommented:
Try the WITH-Clause

Coding Best Practices - Using Subqueries
http://oracleopedia.com/wiki/Coding_Best_Practices_-_Using_Subqueries
0
sdstuberCommented:
please provide sample data and expected results
0
awking00Information Technology SpecialistCommented:
In addition to sample data and expected results, please provide version of Oracle.
0
philsivyerAuthor Commented:
ORACLE 11G
0
philsivyerAuthor Commented:
I am (rightly or wrongly) using XMLAGG to join rows together in one string which returns something like..
'ID1','ID2','ID3','ID4'


pivot
(
   SUM(Amount)
   FOR ID IN (

SELECT
*
FROM
(
SELECT
SUBSTR(
''''||REPLACE(FEE_DESCRIPTION,',',''','''),
0,
LENGTH(''''||REPLACE(FEE_DESCRIPTION,',',''',''')
)-2) AS ID
FROM
(
SELECT
       RTRIM(
           EXTRACT(XMLAGG(XMLELEMENT("s",FEE_DESCRIPTION || ',')), '/s/text()').getstringval(),  ' '    )
           FEE_DESCRIPTION
           
FROM ETC ETC
0
sdstuberCommented:
please,  sample data and expected results
0
philsivyerAuthor Commented:
SEE ATTACHED
DATA-SET.xls
0
sdstuberCommented:
no you can't have the columns be dynamically generated.

It's part of the SQL rules,  the query must know all of the columns to be retrieved at the time the query is parsed.  Since you won't know the columns until after you already have the results, you can't do it in one sql.
0
sdstuberCommented:
as an alternate approach

either create a bunch of ID columns, sufficient to hold the maximum pivot you might attempt.  If you have too many, the pivot will simply populate the extras with NULL

or use dynamic sql.  
First query to find how many ID columns you'll need, then construct the sql query to have that many columns.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
philsivyerAuthor Commented:
Thanks guys
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.