Relative Content

Tag Archive for sqlpostgresql

Get count of records that matches a particular value in multiple columns

Here is what I need :
I have 4 values – ‘India’,’JapaN,’UsA’ and ‘Russia’. These values are in 2 different columns ‘Country’ and ‘Geography’. I need a report of count of rows in table that has above values in any of the columns.
Example : country name No.of rows
India 5
Japan 4

Max does not return maximum timestamp value

In PostgreSQL 16.1 I have a very large table mytable with a column _modified with type Timestamp with time zone. When I run below query on the whole table, it returns a lower timestamp value compared to when I run the query on as subset of the table.