Solutia: select m1, max (ore) as mx, sum(ore) as sm into temporary tmp from xxx group by m1; select co,co1,n1,l1,tmp.m1,sm from xxx join tmp on xxx.m1=tmp.m1 AND xxx.ore=tmp.mx order by tmp.m1 asc;
PS. Multumesc domnului Sideri pt. solutie! > > Tu vrei sa grupezi inregistrari dupa '22021CC' - inregistrarea cu = > > ore=347 > > si '22022BB' - inregistrarea cu ore=310 ? Presupun ca aici a fost o > > greseala de tastare, si ca in ambele cazuri este vorba despre '22021CC'. > > Nu. Nu este o greseala de tastare! > > > > > Solutia "detaliata" ar fi: > > > > claur=3D# select co,co1,n1,l1,m1,sum(ore) as total from xxx group by > > co,co1,n1,l1,m1; > > co | co1 | n1 | l1 | m1 | total > > ---------+------+-----+------+-----+------- > > 22021CC | 1044 | 637 | S5G8 | 407 | 5 > > 22021CC | 1044 | 637 | S5G8 | 409 | 57 > > 22021CD | 1044 | 637 | S5G8 | 410 | 24 > > (3 rows) > > > > unde: > > claur=3D# select * from xxx; > > co | co1 | n1 | l1 | m1 | ore > > ---------+------+-----+------+-----+----- > > 22021CC | 1044 | 637 | S5G8 | 407 | 5 > > 22021CC | 1044 | 637 | S5G8 | 409 | 47 > > 22021CD | 1044 | 637 | S5G8 | 410 | 24 > > 22021CC | 1044 | 637 | S5G8 | 409 | 10 > > (4 rows) > > > > > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of cristi > > Sent: 23 iunie 2004 11:53 > > To: [EMAIL PROTECTED] > > Subject: [rlug] SQL (postgres) > > > > Am urmatorul tabel a carui structura este: > > > > CREATE TABLE "xxx" ( > > "co" character varying(7), > > "co1" character varying(9), > > "n1" character varying(15), > > "l1" character varying(5), > > "m1" smallint, > > "ore" bigint > > ); > > > > si ale caror date continute de acesta sunt: > > > > 22021CC 1044 637 S5G8 407 5 > > 22021CC 1044 637 S5G8 409 47 > > 22021CD 1044 637 S5G8 410 24 > > 22022BB 1044 637 S5G8 409 10 > > > > Vreau o instructiune sql a carui rezultat sa fie de forma: > > > > 22021CC 1044 637 S5G8 407 5 > > 22021CC 1044 637 S5G8 409 57 > > 22021CD 1044 637 S5G8 410 24 > > > > Cu alte cuvinte: > > Sa selecteze numai inregistrarea pt. care co1,n1,l1,m1 este acelasi si > > are > > valoarea cea mai mare de ore adaugandu-se la aceasta valoarea orelor de > > la > > celelalte care dispar. > > > > Va multumesc anticipat! > > > > > > > > ---=20 > > Detalii despre listele noastre de mail: http://www.lug.ro/ > > > > > > > > > > > > > > > > -------------------------------------------------------------------------= > > ------ > > The content of this communication is classified as Mobifon SA Romania = > > Confidential and Proprietary Information.The content of this = > > communication is intended solely for the use of the individual or entity = > > to whom it is addressed and others authorized to receive it. If you are = > > not the intended recipient you are hereby notified that any disclosure, = > > copying, distribution or taking any action in reliance on the contents = > > of this information is strictly prohibited and may be unlawful. If you = > > have received this communication in error, please notify us immediately = > > by responding to this communication then delete it from your system. We = > > appreciate your assistance in preserving the confidentiality of our = > > correspondence. Thank you. > > > > Prezentul mesaj constituie o Informatie confidentiala si este = > > proprietatea exclusiva a MobiFon S.A.. Mesajul se adreseaza numai = > > persoanei fizice sau juridice mentionata ca destinatara, precum si altor = > > persoane autorizate sa-l primeasca. In cazul in care nu sunteti = > > destinatarul vizat, va aducem la cunostinta ca dezvaluirea, copierea, = > > distribuirea sau initierea unor actiuni pe baza prezentei informatii = > > sunt strict interzise si atrag raspunderea civila si penala. Daca ati = > > primit acest mesaj dintr-o eroare, va rugam sa ne anuntati imediat, ca = > > raspuns la mesajul de fata, si sa-l stergeti apoi din sistemul dvs. = > > Apreciem si va multumim pentru sprijinul acordat in pastrarea = > > confidentialitatii corespondentei noastre.=20 > > -------------------------------------------------------------------------= > > ------ > > > > --- > > Detalii despre listele noastre de mail: http://www.lug.ro/ > > > > > > > > --- > Detalii despre listele noastre de mail: http://www.lug.ro/ > > --- Detalii despre listele noastre de mail: http://www.lug.ro/
