tag:blogger.com,1999:blog-11965249.post9007291585427161339..comments2024-01-15T11:31:46.282+01:00Comments on Rudy's DBland: Analytics - n.3: un indovinello con COUNTRudyhttp://www.blogger.com/profile/05494812158299383717noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-11965249.post-63940637546880073712009-06-10T13:43:56.212+02:002009-06-10T13:43:56.212+02:00Ho risolto il problema dei duplicati, ma non mi vi...Ho risolto il problema dei duplicati, ma non mi viene in mente niente per usare il count<br /><br />with tutte_le_eta as ( select rownum eta <br /> from all_objects <br /> where rownum <= 36 )<br />select distinct eta_1, eta_2, eta_3<br />from( select least( a.eta, b.eta, c.eta ) eta_1<br /> , case when a.eta <= b.eta and b.eta <= c.eta then b.eta <br /> when a.eta <= c.eta and c.eta <= b.eta then c.eta<br /> when b.eta <= a.eta and a.eta <= c.eta then a.eta<br /> when b.eta <= c.eta and c.eta <= a.eta then c.eta<br /> when c.eta <= a.eta and a.eta <= b.eta then a.eta<br /> when c.eta <= b.eta and b.eta <= a.eta then b.eta<br /> end eta_2<br /> , greatest( a.eta, b.eta, c.eta ) eta_3<br /> from tutte_le_eta a, tutte_le_eta b, tutte_le_eta c<br /> where a.eta * b.eta * c.eta = 36<br /> )<br />order by 1,2,3;Anonymoushttps://www.blogger.com/profile/15828341895253441244noreply@blogger.comtag:blogger.com,1999:blog-11965249.post-57520062996893187262009-06-10T08:55:19.718+02:002009-06-10T08:55:19.718+02:00@Mauro: sì ma è solo il primo passo: non escludi i...@Mauro: sì ma è solo il primo passo: non escludi i duplicati (1,4,9 4,1,9 9,4,1 ecc.) e non dai la soluzione.<br /><br />Al posto di "select... from dual" io utilizzerei un generatore di numeri meno prolisso e più facilmente riutilizzabile:<br />ad esempio, select rownum from all_objects where rownum <= 36Rudyhttps://www.blogger.com/profile/03336758415691248899noreply@blogger.comtag:blogger.com,1999:blog-11965249.post-26518365953380449092009-06-10T08:11:53.202+02:002009-06-10T08:11:53.202+02:00Tutte le soluzioni senza funzioni analitiche ma so...Tutte le soluzioni senza funzioni analitiche ma solo sql, vale lo stesso?<br /><br />with tutte_eta as ( select 1 eta from dual<br /> union all<br /> select 2 from dual<br /> union all<br /> select 3 from dual<br /> union all<br /> select 4 from dual<br /> union all<br /> select 5 from dual<br /> union all<br /> select 6 from dual<br /> union all<br /> select 7 from dual<br /> union all<br /> select 8 from dual<br /> union all<br /> select 9 from dual<br /> union all<br /> select 10 from dual<br /> union all<br /> select 11 from dual<br /> union all<br /> select 12 from dual<br /> union all<br /> select 13 from dual<br /> union all<br /> select 14 from dual<br /> union all<br /> select 15 from dual<br /> union all<br /> select 16 from dual<br /> union all<br /> select 17 from dual<br /> union all<br /> select 18 from dual<br /> union all<br /> select 19 from dual<br /> union all<br /> select 20 from dual<br /> union all<br /> select 21 from dual<br /> union all<br /> select 22 from dual<br /> union all<br /> select 23 from dual<br /> union all<br /> select 24 from dual<br /> union all<br /> select 25 from dual<br /> union all<br /> select 26 from dual<br /> union all<br /> select 27 from dual<br /> union all<br /> select 28 from dual<br /> union all<br /> select 29 from dual<br /> union all<br /> select 30 from dual<br /> union all<br /> select 31 from dual<br /> union all<br /> select 32 from dual<br /> union all<br /> select 33 from dual<br /> union all<br /> select 34 from dual<br /> union all<br /> select 35 from dual<br /> union all<br /> select 36 from dual )<br />select a.eta, b.eta, c.eta, a.eta + b.eta + c.eta somma<br />from tutte_eta a, tutte_eta b, tutte_eta c<br />where a.eta * b.eta * c.eta = 36<br />order by a.eta, b.eta, c.etaAnonymoushttps://www.blogger.com/profile/15828341895253441244noreply@blogger.comtag:blogger.com,1999:blog-11965249.post-4534588252564372302008-12-01T13:55:00.000+01:002008-12-01T13:55:00.000+01:00Non utilizzi tutti i dati a disposizione.Cmq dovre...Non utilizzi tutti i dati a disposizione.<BR/><BR/>Cmq <B>dovresti utilizzare SQL</B>, perché è un esercizio divertente :-)<BR/>Ah, anche <B>la funzione COUNT()</B> in versione analitica.Rudyhttps://www.blogger.com/profile/03336758415691248899noreply@blogger.comtag:blogger.com,1999:blog-11965249.post-41609301923608314842008-12-01T11:50:00.000+01:002008-12-01T11:50:00.000+01:00Scusa, prima ho sbagliato a scrivere.La soluzione ...Scusa, prima ho sbagliato a scrivere.<BR/>La soluzione dipende dal numero di persone nella stanza l'ultima frase ci dice solo che la figlia maggiore non è gemella. Dato che i fattori di 36 sono 1,2,2,3,3 se le persone ad esempio sono 13 allora l'età è 2,2,9 se sono 14 allora 1,4,9 se sono 21 allora 18,2,1 etc..<BR/>Giusto?<BR/>Ciao<BR/>AdrianoWinter Rosehttps://www.blogger.com/profile/14624120571841550567noreply@blogger.comtag:blogger.com,1999:blog-11965249.post-85320841453314619752008-12-01T11:42:00.000+01:002008-12-01T11:42:00.000+01:00Questo commento è stato eliminato dall'autore.Winter Rosehttps://www.blogger.com/profile/14624120571841550567noreply@blogger.com