darksign Posted April 23, 2008 Report Share Posted April 23, 2008 (edited) Man vajag sagrupēt pēc gadiem (datums katram ierakstam savs, tikai gads vienāds, tapēc nevaru grupēt pēc lauka "DATE", jo tad nekas vienkārši nesagrupēsies). $sql = "SELECT EXTRACT(YEAR FROM TABULA.\"DATE\") AS A_YEAR FROM TABULA WHERE ACCOUNT_ID = '123'"; $res = interbase_sql_exec($sql); rezultāts kas man tagad ir $res mainīgajā: Array ( [0] => Array ( [A_YEAR] => 2007 ) [1] => Array ( [A_YEAR] => 2007 ) .... saīsinam mazliet .... [7] => Array ( [A_YEAR] => 2008 ) [8] => Array ( [A_YEAR] => 2008 ) ) bet man vajag lai būtu šādi, ja piem ir tikai 2007 un 2008 konkrētajā gadījumā: Array ( [0] => Array ( [A_YEAR] => 2007 ) [1] => Array ( [A_YEAR] => 2008 ) ) Bet kad mēģinu vienu no šiem variantiem: $sql = "SELECT EXTRACT(Year from TABULA.\"DATE\") AS A_YEAR FROM TABULA WHERE ACCOUNT_ID = '123' GROUP BY EXTRACT(Year from MOVEMENT.\"DATE\")"; vai $sql = "SELECT EXTRACT(Year from TABULA.\"DATE\") AS A_YEAR FROM TABULA WHERE ACCOUNT_ID = '123' GROUP BY A_YEAR"; tad dabūnu tikai error: Dynamic SQL Error SQL error code = -104 Token unknown - line 1, char 105 EXTRACT QUERY: SELECT EXTRACT(Year from TABULA."DATE") AS A_YEAR FROM TABULA WHERE ACCOUNT_ID = '123' GROUP BY EXTRACT(Year from TABULA."DATE") vai Dynamic SQL Error SQL error code = -104 Token unknown - line 1, char 105 EXTRACT QUERY: SELECT EXTRACT(Year from TABULA."DATE") AS A_YEAR FROM TABULA WHERE ACCOUNT_ID = '123' GROUP BY A_YEAR Kā šādu lietu var uztaisīt InterBase ? Edited April 23, 2008 by darksign Link to comment Share on other sites More sharing options...
darksign Posted April 23, 2008 Author Report Share Posted April 23, 2008 hmm, nevar saprast, vai neviens nezin kaa to triku uztaisiit, vai arii negrib izlasiit to ko esmu uzrakstiijis... varbuut citam patiik ka uzraksta maz un veelaak desmit reizes prasiit lai shamais siikaak paskaidro ko grib un iemet kodu :? , bet ja izskaidro probleemu uzreiz tad neviens laikam nelasa... neizprotu tautu :D p.s. nu bet ja nezin kaa to ar sql, varbuut ir kaada php funkcija jau gatava .. ? vai arii jaaraksta pasham... ??? Link to comment Share on other sites More sharing options...
bubu Posted April 23, 2008 Report Share Posted April 23, 2008 Varbūt tu nevari vienkārši saprast to, ka te nevienam nemaksā par sēdēšanu forumā 24h onlainā. Šeit viss notiek brīvprātīgi. Kad kāds atnāks un izlasīs tavu jautājumu, tad arī atbildēs. Pagaidi pāris stundas vai kādu dienu un tikai tad čīksti, ka neviens neatbild.. Es pats FireBird nezinu, bet MySQL'ā unikālo vērtību izselektēšanu dara ar DISTINCT: SELECT DISTINCT EXTRACT(Year from ...) .... Link to comment Share on other sites More sharing options...
darksign Posted April 23, 2008 Author Report Share Posted April 23, 2008 paldies bubu.. par distinct biju piemirsis :) nostrādāja arī iekš InterBase :) Link to comment Share on other sites More sharing options...
Recommended Posts