Vebers Posted January 11, 2006 Report Share Posted January 11, 2006 (edited) Vai ir k-kā iespējams saskaitīt visus skaitļus kas ir doti vienā kolonnā ? piemērs: id || skaitlis 1 || 2 2 || 7 3 || 6 Rezultātam vaidzētu būt : 15 . Edited January 11, 2006 by MakaTaNaw Link to comment Share on other sites More sharing options...
goldy Posted January 11, 2006 Report Share Posted January 11, 2006 (edited) SELECT COUNT(skaitlis) .... Edited January 11, 2006 by goldy Link to comment Share on other sites More sharing options...
bubu Posted January 11, 2006 Report Share Posted January 11, 2006 goldy: wtf? :) SELECT SUM(skaitlis) FROM tabule [WHERE ... ] Link to comment Share on other sites More sharing options...
Grey_Wolf Posted January 11, 2006 Report Share Posted January 11, 2006 (edited) goldy--> garaam ;) peec dotaa piemeera rez. buus 3 COUNT() atgriezj rindinju skaitu kuraas nav NULL un atbilst dotajam nosacijumam shajaa gadijumaa vajag SUM() SUM(skaitlis) -------- SUM()--> atgriezj summu ;) MYSQL un SQL vispaar ir Ljoti daudz efektiivu panjeemienu kaa atlasiit vajadziigos datus... dazreiz pat pabriinos kaa ir izveidotas dazas PHP progas --> 50 un vairaak rindinju kur vajadzeetu 1 pareizu SQL pieprasijumu ;) edit: bubu jau pasteidzaas ;) Edited January 11, 2006 by Grey_Wolf Link to comment Share on other sites More sharing options...
Vebers Posted January 11, 2006 Author Report Share Posted January 11, 2006 Tad pie reizes kā var sareizināt, atņemt un izdalīt ? ;) Link to comment Share on other sites More sharing options...
Grey_Wolf Posted January 11, 2006 Report Share Posted January 11, 2006 (edited) Tad pie reizes kā var sareizināt, atņemt un izdalīt ? ;) reizinaashana * atnjemshana - daliishana / ;) edit: starp citu visaa nopietniibaa -SQL sintakse to atljauj Edited January 11, 2006 by Grey_Wolf Link to comment Share on other sites More sharing options...
Vebers Posted January 11, 2006 Author Report Share Posted January 11, 2006 Nu to jau var izmantot pie update vai tomēr arī pie select ? Un vai nebūs pie select piem., STARPIBA(skaitlis) , REIZINAJUMS(skaitlis), DALIJUMS(skaitlis) ? :) Link to comment Share on other sites More sharing options...
Grey_Wolf Posted January 11, 2006 Report Share Posted January 11, 2006 (edited) MakaTaNaw --> nezinu ko ar to visu biji dmaajis ... kautkaa murgaini izskataas :( WHERE nosacijumu var lieto pie SELECT, UPDATE , DELETE... taatad lauks - lauks2=kautko .... arii pie dazjiem SELEC nosacijumiem var izmantot matem. darbiibas SELECT skaitlis-kautkaads_cits_skaitlis AS nosaukums.... Edited January 11, 2006 by Grey_Wolf Link to comment Share on other sites More sharing options...
goldy Posted January 11, 2006 Report Share Posted January 11, 2006 :))) jaa jaa sorry nezkaapeec pa fikso izdomaaju ka COUNT buus tas iistas, tagad ieliidu izlabot savu kluudu a te jau Link to comment Share on other sites More sharing options...
Vebers Posted January 11, 2006 Author Report Share Posted January 11, 2006 Grey_Wolf: Ar to biju domājis vai nav kādi 'aizstājēj vārdiņi' gluži kā ir SUM(skaitlis) - summai, tad starpībai reizinājumam un dalījumam tādi nav ? Varbūt parādi piemēru kā izskatīsies šīs kolonnas starpība (skaitlis_1 - skaitlis_2 - skailis_3 lai sanāk -11 ) ? Link to comment Share on other sites More sharing options...
bubu Posted January 11, 2006 Report Share Posted January 11, 2006 (edited) Tā jau nav kolonnas starpība. Tā ir no ieraksta ar ID=1 atņemtu ierakstu ar ID=2 un ID=3 summa. Edited January 11, 2006 by bubu Link to comment Share on other sites More sharing options...
Grey_Wolf Posted January 11, 2006 Report Share Posted January 11, 2006 MakaTaNaw--> skjiet ka nav gan.... vispaar pameklee pats ;) roc aggregatefunctions virzienaa.. zinu ka ir MAX() --> lielaakaa kolonas veertiiba MIN()--> mazaakaa kolonas vertiiba AVG() --> videejaa kolonas veertiiba COUNT(), SUM(), un vel dazas.... P.S. sakumaa iisti neiebraucu tavaa jautaajumaa.... Link to comment Share on other sites More sharing options...
Vebers Posted January 11, 2006 Author Report Share Posted January 11, 2006 Raku un neizraku nekādus tādus group by kā sum :( hmm.. laikam nāksies vien pie tabulas (html) ģenerēšanas skaitīt ar PHP katras row vērtību :) Nav ko velosipēdu no jauna laikam izgudrot, he Link to comment Share on other sites More sharing options...
Grey_Wolf Posted January 11, 2006 Report Share Posted January 11, 2006 MakaTaNaw--> ??? tevtachu gan bubu gan es pateicu atriinaajumu ;) ir taada f-ja kaa SUM(kolona) un nevajag nekaadus group by paskaties ko bubu uzrakstija... tik pieliec klaat AS nosaukums SELECT SUM(skaitlis) AS kautkads_nebuut_nosaukums FROM tabula....... un kautkads_nebuut_nosaukums buus visas kolonaas skaitlju summa.... Link to comment Share on other sites More sharing options...
Vebers Posted January 11, 2006 Author Report Share Posted January 11, 2006 Vai, jā! Pavisam jau izkrita no galvas, he bet pie atņemšanas gan būs tā jādara.. Link to comment Share on other sites More sharing options...
Recommended Posts