DBFlow icon indicating copy to clipboard operation
DBFlow copied to clipboard

Select Max, Min, Avg function?

Open gnuhel opened this issue 11 years ago • 5 comments

How can I select something like this SELECT max(salary) FROM COMPANY;

gnuhel avatar Mar 25 '15 21:03 gnuhel

currently i have used

Cursor cursor = new Select().method("MAX","salary").from(company.class).query();

mwinters-stuff avatar Mar 26 '15 01:03 mwinters-stuff

Yeah I mean I could have added more functions, just at some point it may be a lot. so I added the method() method to easily enable other functions.

agrosner avatar Mar 26 '15 02:03 agrosner

@agrosner Sorry to ask you again. how do I get the Max value?

public static int foo() { Cursor cursor = new Select().method("MAX", Ticket$Table.TICKETID).from(Ticket.class).query(); if (cursor != null && cursor.getCount() > 0) { int ticketId = cursor.getInt(0); return ticketId + 1; } return 10000; }

this is my code but how do I get Max column? int ticketId = cursor.getInt(0); is wrong

gnuhel avatar Apr 15 '15 14:04 gnuhel

was this feature removed? can't find method function anymore.

ghost avatar Dec 30 '15 15:12 ghost

Same, can't find that method funcion too

raphaelbgr avatar Jun 28 '19 19:06 raphaelbgr