|
you're right, order by needs added to the over(...) I missed that.
On Mon, Jan 18, 2016 at 4:12 PM, <rob@xxxxxxxxx> wrote:
Somewhere in there is a need for an order by PRDATER (process date).mschutte369@xxxxxxxxx>
But the analytical
row_number() over...
should be the light that clicks on for the OP.
Rob Berendt
From: Michael Schutte <mschutte369@xxxxxxxxx>
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Date: 01/18/2016 04:05 PM
Subject: Re: Complex (for me) SQL question
Sent by: "MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxx>
Add () to the row_number, remove group by from the over(...)
On Mon, Jan 18, 2016 at 3:53 PM, Michael Schutte <mschutte369@xxxxxxxxx>
wrote:
Oops, didn't finish reading.
with sum1 as (
select PRPRDN from HPRDFA
group by PRPRDN
HAVING COUNT(1) > 1
), results as (
select HPRDFA.*, row_number over(partition by PRPRDN group by PRPRDN)
row_number_by_item
from HPRDFA
where PRPRDN in (select PRPRDN from sum1) )
select * from results
where row_number_by_item <= 2
On Mon, Jan 18, 2016 at 3:51 PM, Michael Schutte <
wrote:
Would this suffice?
select PRPRDN from HPRDFA
group by PRPRDN
HAVING COUNT(1) > 1
order by PRPRDN
Or
with sum1 as (
select PRPRDN from HPRDFA
group by PRPRDN
HAVING COUNT(1) > 1
)
select * from HPRDFA
where PRPRDN in (select PRPRDN from sum1)
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.