Ho raggruppato in questa pagina qualche 'chicca' di programmazione che ho raccolto durante gli anni di lavoro come ingegnere informatico.
I linguaggi di programmazione utilizzati sono principalmente Java e SQL anche se conto di aggiungere tips in altri linguaggi, magari anche con i vostri contributi. Ho voluto mette solo quelle routine che permettono di avere un risultato apprezzabile utilizzando pochissime linee di codice...che sono le mie preferite!

I have gathered here some 'gem' of programming that I have collected over the years working as a software engineer. The programming languages used are mainly Java and SQL even if I hope to add tips in other languages, even with your contributions. I posted only those routines that allow for a successful result using very few lines of code ... which are my preferred!


mercoledì 22 aprile 2009

[SQL] SELEZIONARE ELEMENTI CON DUPLICATI - TAKE THE ROWS WITH DUPLICATE FIELDS

  SELECT *
  FROM table t1,
   (select MAX(key) key,field
   FROM table
   GROUP BY field) t2
  WHERE t1.key<>t2.key AND t1.field=t2.field



Dove 'key' è la chiave della tabella e 'field' è il campo dove cercare i valori duplicati


Where 'key' is the table key and 'field' is the field where check the duplicates

Nessun commento:

Posta un commento