nacer@hpmcaa.mcm.hp.com (Abdenacer Moussaoui) (05/01/91)
I need help figuring out an SQL query to select unique rows with respect to a set of fields. Let T be a table with active unique index on k1, k2 field. I would like to select rows such that combination of values in fields f1, f2 and f3 appear only once. I don't care which row's keys (k1, k2) I get as long as I get one and only one with for each given unique instance of f1, f2, f3. When I use select count(*), f1, f2, f3 from T group by f1, f2, f3 I get a distribution of the different variations of f1..f3 fields, now how do I include in the selection k1 and k2 fields? I have looked in C.J book on possibly using aliases but at this point I have no clue how to do this. Thank you so much. -- Thank you. --Abdenacer (nacer@hpmcaa.mcm.hp.COM)
hansene@hpcc01.HP.COM (Ed Hansen) (05/07/91)
The following query will retrieve all the distinct combination of f1 , f2, f3 that occur in table T: SELECT DISTINCT f1 , f2, f3 FROM T JeanMarie