Vebers Posted April 21, 2006 Report Share Posted April 21, 2006 (edited) Kā, lai pieprasa no tabulas minimālo unikālo vērtību? SELECT MIN(DISTINCT kicks), user_id FROM table GROUP BY user_id <-- nedarbojas.. Edited April 21, 2006 by MakaTaNaw Link to comment Share on other sites More sharing options...
bubu Posted April 21, 2006 Report Share Posted April 21, 2006 SELECT MIN(x) FROM (SELECT x, COUNT(x) AS cx FROM tabule GROUP BY x HAVING cx=1) Link to comment Share on other sites More sharing options...
Vebers Posted April 22, 2006 Author Report Share Posted April 22, 2006 (edited) Paldies, nostrādāja šādi. SELECT min(kicks), user_id FROM (SELECT kicks, user_id, COUNT(user_id) AS cx FROM tabula GROUP BY kicks HAVING cx=1) as tbl1; Edited April 22, 2006 by MakaTaNaw Link to comment Share on other sites More sharing options...
bubu Posted April 22, 2006 Report Share Posted April 22, 2006 A kam tev minimālo vajadzēja prasīt? Tavs kverijs taču pierakstās vienkāršāk (tie ieraksti, kuru user_id ir unikāli pa visu tabulu, tb vieni vienīgie): SELECT kicks, user_id, COUNT(user_id) AS cx FROM tabula GROUP BY kicks HAVING cx=1 Link to comment Share on other sites More sharing options...
Delfins Posted April 22, 2006 Report Share Posted April 22, 2006 Tā ir ka nemācās augstskolā ;) izdomā visādas perversijas... Link to comment Share on other sites More sharing options...
bubu Posted April 22, 2006 Report Share Posted April 22, 2006 Nu lai šito saprastu nav nekādā augstskolā jāmācās. Link to comment Share on other sites More sharing options...
Vebers Posted April 22, 2006 Author Report Share Posted April 22, 2006 Tā ir ka nemācās augstskolā ;)izdomā visādas perversijas... Esmu augstskolai par jaunu. Minimālo vērtību vaidzēja, lai to varētu salīdzināt ar lietotāja piedāvāto vērtību (pārbaudīt vai tā ir unikāla un zemākā). Bet kam tādā gadījumā ir domāts MIN(DISTINCT expr) ? Link to comment Share on other sites More sharing options...
bubu Posted April 22, 2006 Report Share Posted April 22, 2006 Es nesaprotu, ko tu tur piesauc kautkādu minimālo vērtību, kaut arī tavā kverijā (no posta #3) nav nekāds MIN fjas pielietojums. imo MIN(DISTINCT expr), ja šis pieraksts vispār ir sintaktiski korekts, ir ekvivalents ar MIN(expr). Link to comment Share on other sites More sharing options...
Vebers Posted April 22, 2006 Author Report Share Posted April 22, 2006 Eh, nepareizi šeit ierakstīju to query. (izlaboju) Link to comment Share on other sites More sharing options...
bubu Posted April 22, 2006 Report Share Posted April 22, 2006 Ā, nu tā ir cita lieta. Tad viss skaidrs. Link to comment Share on other sites More sharing options...
Recommended Posts