How to perform a SELECT DISTINCT - H2

Asked

Viewed 140 times

0

I need to perform a SELECT DISTINCTin 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 PostgreSQLand 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.lol No table is not empty kkk

  • Try it like this: ORDER BY 1 ASC

  • @Reginaldorigo the 1 you say in the case is the letter L of lot?

  • No. It is the numeral 1 even. It means to SORT by the FIRST column.

  • It wasn’t like @Reginaldorigo

  • Is there any other way to use the same Distinct Function other than by it?

  • 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.

  • Thanks for the help @Reginaldorigo

  • 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 a select distinct...

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.