There is a certain table tbl :
id | f_key | alive ------------------- | | There are fields, but they do not matter.
I want to find out if I have more than one live record at the moment (alive = true) related to one 'f_key'.
What can I do myself:
I can write a simple request
select * from tbl where alive = true order by f_key; and see for yourself: if there are identical f_key in two or more lines in a row, then this is what I'm looking for.
But I would like to automate this work somehow. I understand that the question is very simple, and you just need to vkoryachit somewhere in the condition aggregate function count() , the value of which is more than one, but I'm confused where.