Re: Problem with max(ROW)
From: Vladimir M. Zakharychev <bob_at_dpsp-yes.com>
Date: Tue, 1 Oct 2002 17:23:05 +0400
Message-ID: <anc7mu$jl1$1_at_babylon.agtel.net>
Date: Tue, 1 Oct 2002 17:23:05 +0400
Message-ID: <anc7mu$jl1$1_at_babylon.agtel.net>
Hmm... Assuming g_datum is actually a date something like this might work:
select * from pprk_aktuell
where (artikel_nr, preis_kz, to_date(g_datum,'your date format'))
in (select artikel_nr ,preis_kz ,max(to_date(g_datum, 'your date format')) from pprk_aktuell group by artikel_nr, preis_kz)
(replace 'your date format' with correct date format for dates in g_datum - if it's indeed a date, that is. Otherwise just remove to_date() call or replace it with to_number() call if column stores a number to avoid implicit data type conversions and bizarre query results that they may produce as a side effect.)
hth.
-- Vladimir Zakharychev (bob_at_dpsp-yes.com) http://www.dpsp-yes.com Dynamic PSP(tm) - the first true RAD toolkit for Oracle-based internet applications. All opinions are mine and do not necessarily go in line with those of my employer. "Andreas Cavaleri" <cav_at_hebenstreit.de> wrote in message news:7617730a.0210010348.2918ced6_at_posting.google.com...Received on Tue Oct 01 2002 - 15:23:05 CEST
> Hi, I need help with a SQL-statement:
> My Table-structure is as follow:
>
> SQLWKS> describe pprk_aktuell
> Spaltenname Null? Typ
> ------------------------------ -------- ----
> ARTIKEL_NR NOT NULL VARCHAR2(35)
> PREIS_KZ NOT NULL VARCHAR2(1)
> G_DATUM NOT NULL VARCHAR2(8)
> PREIS_VK NUMBER(10,2)
> PREIS_TK NUMBER(10,2)
> PPRKPHYSSEQ NOT NULL VARCHAR2(15)
>
> For every ARTIKEL_NR exists up to 6 PREIS_KZ's, it can be A-F.
> For every Preis_KZ there can be multiple rows, but one who has the
> highest G_DATUM.
> I need a Statement which gives only the row with the highest G_DATUM
> for every Group with same ARTIKEL_NR and PREIS_KZ.
> Can anybody help me?
> Thank you for reading!