Ask a Question related to IBM DB2, Design and Development.
-
Ian D Bjorhovde #1
Re: selecting ordered groups out of a table
Rainer Gauweiler wrote:
with recent_orders as (> Hello together,
> I have a table of invoices f.e. invoices (customer,invoice-nr,date). Now I
> want the recent five invoices of each customer.
> I could select all customers and select the five invoices step by step but I
> want to use only one statement. Is there a way? I tried to work with
> subselects or with the with-statement but didn't find the trick. Any ideas?
>
select
customer,
invoice-nr,
date,
row_number() over (partition by customer, order by date desc) as rn
from
invoices
)
select customer, invoice-nr,date
from recent_orders
where rn <= 5;
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
[url]http://www.newsfeeds.com[/url] - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Ian D Bjorhovde Guest
-
Ordered Data Inserted into TEMP table, is Read out in Different ORDER??
Im using a query with OrderBy clause to populate a temp table. The Query works and Order and everything is Fine But when reading the data out of... -
Selecting objects within groups
Help! I'm using CS2 to produce an advertisement for an auto dealer. It consists of a 7x7 grid of 49 vehicles. Each vehicle space consists of a photo... -
Dreamweaver recordset, selecting table
In Dreamweaver 8, when I go to set up a recordset, in the recordset dialog box, the "table" dropdown box indicates a path to the table in the... -
Selecting users that are in multiple groups
I am very new to ColdFusion and am having a light issue trying to select users that are in multiple groups... Basically, I want the sales people... -
SELECTing the 'middle' row in a table (maybe with php?)
A table contains records of Ice Cream flavors. There is a primary id field (INT) and a varchar for flavor. I need to get the row in the very...



Reply With Quote

