Microsoft
Software
Hardware
Network
Question : Select top N and their types
I'm having a bugger of a time writing this SQL query (Oracle 10g)....
I have two tables. For every unique transaction ID in TABLE1, there can be many transaction types associated with it in TABLE2. What I want to do is retrieve the 5 most recent (biggest) transaction IDs in TABLE1 for a given user and all transaction types from TABLE2 associated with those 5 ids. For example if the 5 biggest transaction ids in table TABLE1 are 6-10, and in TABLE2 types "apples" and "oranges" can exist, the output might look like:
Transaction ID / Type
---------------------
6 / apples
7 / apples
8 / apples
8 / oranges
9 / apples
10 / apples
In the example, I have 6 rows returned, but they're still only based on the 5 most recent (biggest) ids.
This is what I have so far. The query is supposed to grab all the types and ids based on the 5 most recent ids.
SELECT t1.unique_id, t2.type_id
FROM TABLE1 t1, TABLE2 t2
WHERE t1.unique_id = t2.unique_id
AND t2.unique_id in (
SELECT t1.unique_id
FROM TABLE1 t1
WHERE t1.user_id = 'myUser'
AND ROWNUM <= 5
)
Any help is appreciated.
Answer : Select top N and their types
I bought a trip lite rack mount UPS. It was mostly DOA on arrival. They sent me another one and now its charging. I have heard locally cyber power is good so I will start using them more.
Random Solutions
What can you tell me about this resx file?
InDesign/MAC PrintBooklet to a PDF file on a mac
vb.net Insert comma every 3 characters
How do I configure exchange 2007 to allow iPhone/iPad to work.
red ant
customized toolbar in Access 2007
Font Question
how to truncate the transaction logs in exchange 2010 after NT backup
XenServer 5.5 The Storage repository is not available.
How to get an USB speaker to work with Eee PC 900 Xandros Linux