0
I need to perform a SELECT DISTINCT
in the database H2
but the way I’m doing it’s not returning anything to me:
SELECT DISTINCT lote
FROM LotesEncerrados l
ORDER BY l.lote ASC
I did the same in the PostgreSQL
and worked normally. How could I do in the H2
?
For documentation this standard use of syntax seems to be correct, H2 doesn’t seem to need anything different... Stupid question on my part, but the table is not empty, is it? Hahah...
– nunks
@nunks.lol No table is not empty kkk
– R.Santos
Try it like this: ORDER BY 1 ASC
– Reginaldo Rigo
@Reginaldorigo the 1 you say in the case is the letter L of lot?
– R.Santos
No. It is the numeral 1 even. It means to SORT by the FIRST column.
– Reginaldo Rigo
It wasn’t like @Reginaldorigo
– R.Santos
Is there any other way to use the same Distinct Function other than by it?
– R.Santos
Not that I know of. I tested here on H2, with a table with structure similar to yours and it worked, both with your SELECT and with what I suggested. The problem isn’t H2 and I can’t imagine what it would be.
– Reginaldo Rigo
Thanks for the help @Reginaldorigo
– R.Santos
Well, since you’re only searching for a column, the query
select lote from LotesEncerrados group by lote order by lote;
should have the same effect as aselect distinct
...– nunks