jeudi 30 juillet 2015

wrong result in java with sqlite using having

I have a table with following data

taskid   bind_address           type_id
1        tcp://10.10.1.2:8001   3
1        tcp://127.0.0.1:8000   2
2        tcp://10.10.1.2:8003   3
2        tcp://127.0.0.1:8002   2
3        tcp://10.10.1.2:8005   3
3        tcp://127.0.0.1:8004   2
4        tcp://10.10.1.3:8007   3
4        tcp://127.0.0.1:8006   2
5        tcp://10.10.1.4:8009   3
5        tcp://127.0.0.1:8008   2
6        tcp://10.10.1.4:8011   3
6        tcp://127.0.0.1:8010   2
7        tcp://10.10.1.5:8011   3
7        tcp://127.0.0.1:8012   2

with this sqlStatement

select task_id, bind_address,type_id 
From task_pub tp    
join task t   
    on tp.task_id=t.id  
join host h                          
    on t.host_id=h.id   
where h.id=3                      
group by h.id, task_id      
having min(type_id);

Per task I want to get just the row with the lowest type_id If I execute this statement with sqlite3 I get this as result

2        tcp://127.0.0.1:8002   2
5        tcp://127.0.0.1:8008   2
6        tcp://127.0.0.1:8010   2

but with java and the jdbc driver for sqlite I get this (wrong) result

2        tcp://10.10.1.2:8003 3
5        tcp://10.10.1.4:8009 3
6        tcp://10.10.1.4:8011 3

the sql statement in java is 100% right, I copied the statement in debug-mode

Aucun commentaire:

Enregistrer un commentaire