greddin
asked on
Help with SQL statement
I have a couple of different sql queries that each in their own right give me what I need. But I would like to merge the two together as one report.
Is it possible to have an outer select with an inner select?
The first select is returning an ID. On the second (inner) select I would like to pass in the ID from the outer select.
How could I do this?
Thanks
Is it possible to have an outer select with an inner select?
The first select is returning an ID. On the second (inner) select I would like to pass in the ID from the outer select.
How could I do this?
Thanks
Code you please explain it more..
Could you please explain your question with some samples..
ASKER
First first select statement returns a list of CollectionIDs Like this:
CollectionID
------
1
2
3
4
5
and so on
My second query does takes a given CollectionID and counts a DocType that are in each CollectionID.
Like this:
DocType Total
------- -----
type1 12
type2 6
type3 8
type4 2
type5 16
I would somehow like to merge these two results into one and return something like this:
CollectionID DocType Count
------------ ------- -----
1 type1 12
1 type2 6
1 type3 8
1 type4 2
1 type5 16
2 type1 2
2 type2 10
2 type3 5
2 type4 3
2 type5 9
..continue until all CollectionIDs are done.
Does this make sense?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
IS the above comment is what your looking for ?
or
do you have two seperate queries for frist and secrion statements. >
or
do you have two seperate queries for frist and secrion statements. >
ASKER
Right now I have two separate queries that run on different tables of the same database.
what r the queries ?
ASKER
Thanks for this response. Based on this I was able to get what I needed.