473,412 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Top N results

I'm trying to get to last four prices we've payed for a sub-set of parts. I'm able to get the last four prices we've payed for a particular part but I want to exted it to all parts. the current query I have is:

Expand|Select|Wrap|Line Numbers
  1. SELECT HIST.*, ROWNUM
  2.   FROM (SELECT APD.Part_Number,
  3.                            APD.Actual_Unit_Price
  4.                 FROM AP_DETAIL APD
  5.              WHERE APD.Part_Number = 'XXXXXXXXXX'
  6.              ORDER BY APD.Entered_Date DESC) HIST
  7.  WHERE ROWNUM <= 4
I just need to get rid of the where clause in the inline view and I would have the result I need. Is there any way to do this?
May 19 '08 #1
1 1321
amitpatel66
2,367 Expert 2GB
I'm trying to get to last four prices we've payed for a sub-set of parts. I'm able to get the last four prices we've payed for a particular part but I want to exted it to all parts. the current query I have is:

Expand|Select|Wrap|Line Numbers
  1. SELECT HIST.*, ROWNUM
  2.   FROM (SELECT APD.Part_Number,
  3.                            APD.Actual_Unit_Price
  4.                 FROM AP_DETAIL APD
  5.              WHERE APD.Part_Number = 'XXXXXXXXXX'
  6.              ORDER BY APD.Entered_Date DESC) HIST
  7.  WHERE ROWNUM <= 4
I just need to get rid of the where clause in the inline view and I would have the result I need. Is there any way to do this?
Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT HIST.*
  3.   FROM (SELECT APD.Part_Number,row_number() OVER(PARTITION BY part_number ORDER BY part_number) rnk
  4.                            APD.Actual_Unit_Price 
  5.                 FROM AP_DETAIL APD
  6.              --WHERE APD.Part_Number = 'XXXXXXXXXX'      ) HIST
  7.  WHERE rnk <= 4
  8. ORDER BY part_number,rnk
  9.  
  10.  
May 23 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Francisco | last post by:
I have this question: I have a simple search to a db, something like: "select description from games where year = '1990'" suppose I get 300 results, I would like to display this in pages of 30...
4
by: Aaron Reimann | last post by:
I am trying to build a table using results from a database query. Right now (code below), the code displays each result in a new <tr>. I am wanted to display 3 results in one <tr> </tr>, and then...
2
by: CharitiesOnline | last post by:
Hello, I have set this script up to add paging to a search results page. Which on the first page works fine. I calculates how many pages there should be depending on the number of results returned...
5
by: George | last post by:
Hi, Anyone has the background for explaining? I have made a search on my name and I have got a link to another search engine. The link's title was the search phrase for the other search engine...
6
by: Jules | last post by:
Hi: I have an Access 97 Search form set up - a couple of combo boxes, a couple of text fields and a command button. I want the command button to run an SQL script and then open the results form....
1
by: Don | last post by:
I am new to Indexing Services, have been researching the MS Site as well as web articles on DevHood, etc. I have set up a seperate catalog ("KnowledgeBase") on Win XP with a number of files. I am...
0
by: Rob | last post by:
I doubt this is the best way to do it, but what I came up with was to hide the XML in an HTML Comment then edit the file deleting the HTML stuff and keep the XML results. If anyone has a better...
4
by: jaYPee | last post by:
I have downloaded some source code but I want this to convert the results into datagrid. dr = cmd.ExecuteReader() '**************************************** ' SHOW THE RESULTS...
1
by: oaklander | last post by:
Is it okay to keep creating queries with the same ResultSet Object reference (results)? Here is what I am currently using in my Database statements with Oracle and everything works but was wondering...
3
by: Bigalan | last post by:
Hello, i am relatively new to PHP and i am struggling with printing multiple search results on to different pages. The code below works ok but when you click on next page button, it brings up a blank...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.