1
vote
1answer
24 views

Summing different tables values limiting the results

I have two tables (a and b) which have both one date field of type TIMESTAMP. They represent two different type of actions (records): table a's actions are $200 worth each, while table b's ones worth ...
1
vote
2answers
96 views

First Database Schema - How did I do?

I would really like some advice from any DB gurus who have a few minutes free. After doing some reading and playing with sqlfiddle over the weekend I have constructed this postgresql schema and it is ...
3
votes
2answers
87 views

PostgreSQL simple query with repeated function calls

I have PostgreSQL 9.1.1 running in a shared hosting environment and I'm running this query: SELECT a.id, CASE WHEN a.idpai IS NULL THEN a.nome ELSE concat(a.nome, ' (', b.nome, ')') END AS nome, ...
2
votes
0answers
43 views

Low performance of PL/pgSQL function

I have a PL/pgSQL function which is unstable. This is source: DECLARE l RECORD; events_for_machine integer; before_event "PRD".events_log; machines_ids integer[]; island_controller RECORD; ...
6
votes
2answers
597 views

SQL: Search for a keyword in several columns of a table

I want to perform a search in several columns of a table. I use the following query: select * from Tabela t inner join "TabelaPai" tp on tp."ID" = t."RefTabelaPai" and tp."RefProject" = 'projectid' ...
6
votes
2answers
669 views

SQL: Extracting nodes from a graph database

I guess I'm one of these people who are more at home in C#,C++, Python, etc; and only use SQL to do simple INSERTs and SELECTs, so apologies if this is too simple. I'm also new to Postgres and ...