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
my phone number would accept
Is it possible to exclude certain project folders like Images during Publish?
Network issue.
windows 2008 r2 with raid 6
Should 3rd party drivers start in safe mode?
In Outlook, Advanced Find - Search for Attachment name
Configuring QoS on Linksys Cisco IP VOIP phone system through residential ADSL2
ipconfig shows lots of "tunnel adapters", what are they?
What is message collison?
How to select all child DIVs except where class=...