[Gvsig_desarrolladores] group by en GDBMS

dani.gonzalez dani.gonzalez en geodata.es
Jue Abr 7 18:23:47 CEST 2011


Gracias por la respuesta Francisco, he podido avanzar un poquito más :)

ahora me encuentro con otro problema. Si hago la query poniendo los campos
del group by también en el select:

String sql = "select " + field_1_Name + ", " + field_2_Name + ", count(" +
field_2_Name + ") as total from '" + sds.getName() + "' group by " +
field_1_Name + ", " + field_2_Name + ";";
DataSource ds = sds.getDataSourceFactory().executeSQL(sql,
DataSourceFactory.MANUAL_OPENING);	

ds.getRowCount(); me devuelve 12767 resultados, así que el group by
funciona.
pero cuando itero por los resultados:

SelectionFieldIterator iterator = new SelectionFieldIterator(ds, selection,
2);			     
String  total = "";
while(iterator.hasNext()) {
    	 total =
iterator.next().getStringValue(ValueWriter.internalValueWriter);			    
}

al debugar esto, el valor de "total" va siendo 1, 2, 3, 4,..., 12767 (). La
función "count" no funciona como debería, o estoy iterando mal por los
resultados de la query?


Dani González Moratona
dani.gonzalez en geodata.es
________________________
Geodata Sistemas, S.L.
C/Bac de Roda 136 1r 1a

Telf: 93.303.53.67
http://www.geodata.es





--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/group-by-en-GDBMS-tp6250025p6250645.html
Sent from the gvSIG desarrolladores mailing list archive at Nabble.com.


Más información sobre la lista de distribución gvSIG_desarrolladores