Skip to content
Advertisement

Tag: postgresql

How do I join a string and an int in PostgreSQL?

I have a procedure with an int parameter. The syntax for the add_retention_policy function is add_retention_policy(‘hypertable’, INTERVAL ‘x days’, true). I want to prefix the hypertable with the schema which is always ‘schema_’ and then followed by the id parameter, how do I do that? Answer You just need to rewrite the INTERVAL part in your function call as days

Consider two left join with same table SQL

I have this query I need to consider procedimentos when faturamento_lancamentos_bpa_adicionais.procedimento_id and faturamento_lancamentos_bpa.procedimento_id Answer You need to alias the “doubled” tables, as every entity needs a unique name The use of meaningful aliases will keep also the query better readable

How to apply this query to all the employees

I have a query to compute the 3rd highest salary for an employee as shown below. How can I apply this query to give the 3rd highest salary for each employee which can be fetched by the query Note: without using special functions like dense_rank() Answer You are looking for each employee’s third highest salary. It can happen that we

Save few values to the row in Postgres [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 months ago. Improve this question Is it possible to save few values to the row. For example, I have 2 tables: For Participants: And for Voters: I want to get

SQL query to aggregate result of a column comparison

I have a SQL (Postgres) data structure that represents games for a group of matches. Table below shows that there have been 3 matches played (each consisting of either 2 or 3 games). match_id player_one player_two p1_game_result p2_game_result 1 player1 player2 12 10 1 player1 player2 3 11 1 player1 player2 5 9 2 player1 player3 11 2 2 player1

Advertisement