Tagged Questions
0
votes
1answer
30 views
UPDATE from result of SELECT
I have a problem with updating my table with a select from another table. Here is my description:
Table part has the following fields:
part_num PK
active
notes
weight
Table importedDocument has ...
3
votes
3answers
45 views
Create column from query data
Test data:
create temp table l (id integer,name text);
create temp table t (id integer);
create temp table t_i18n(id integer,l_id integer,t_id integer,name text);
insert into l(id, name) values
(1, ...
0
votes
3answers
52 views
Optimize Postgresql query with order by, left join and limit
Im' looking for help as I can't find a good way to optimize this query :
SELECT
b.book_id,
b.asin,
b.type_book
FROM book b
LEFT JOIN product_maj_plateforme pmp
ON pmp.book_id_fk = b.book_id ...
0
votes
1answer
26 views
PostgreSQL right join with group by
My problem seems to be have an easy solution but I can't get to it.
I have an select joining two tables: users and login_log. I need to show each user and how many logins he has (including the ones ...
2
votes
2answers
43 views
change in value running total of time between
I have a program that periodically records details of a users mobile data connection (signal strength, network technology type, etc) to a single table in PostgreSQL. The relevant fields in the table ...
0
votes
2answers
27 views
LEFT OUTER JOIN loses original userID
Stepping up my PostgreSQL knowledge. Here's a working query:
SELECT *
FROM associates a
LEFT OUTER JOIN ip b
ON a.userID = b.userID AND b.iPAddress = '124.xxx.xxx.xxx'
LEFT OUTER ...
0
votes
3answers
26 views
SELECT from one table, INSERT into two other tables based on condition
I have a Postgres database with 3 tables, say A, B and C. I want to select data from table A and loop through each row checking the value in one of the columns and then insert the data into table B or ...
0
votes
2answers
38 views
Detecting last row of a group
I am using row_number() to determine the last row of a query by creating descending order and checking if I am on position 1.
row | value
----+-------
3 | false
2 | false
1 | true
Do you have ...
1
vote
1answer
33 views
How to insert a Set into a column of type integer[]?
I have a column of type integer[], created with the following query.
...
questions int[] DEFAULT '{}',
...
I am trying to insert a set of integers using Hibernate's query functionality.
...
0
votes
0answers
18 views
PostgreSQL: How to list all stored functions that access specific table [migrated]
Introduction:
PostgreSQL database with several hundred of stored functions, including obsolete, not used etc.
Problem
I need to find out all the stored functions that have any relationship to the ...
2
votes
6answers
79 views
SQL query to show data that exactly match criteria in another table's column
By this time I am implementing a system that perform matching between 3 tables and I am really need your help by now, suppose I have the following three tables:
Table1: Relation between name and ...
0
votes
2answers
27 views
plpgsql cte parameterizing with array cause error message
I'll try to inject and array of ids to a complex select query
CREATE FUNCTION permission_cache_update(
IN affected_user_list INT4[]
)
RETURNS TABLE(user_id INT4, permission_id INT4)
AS
$BODY$
...
0
votes
2answers
41 views
How to speed up min/max aggregates in Postgres without an index that is unnecessary otherwise
Say I have a table with an int column, and all I am ever going to read from it is the MAX() int value.
If I create an index on that column, Postgres can perform a reverse scan of that index to get ...
0
votes
1answer
30 views
JDBC: check stored procedure return value
I have a stored procedure on my postgresql database that return integer value. When i call my procedure form jdbc client using CallableStatement, when i call execute() method on CallableStatement ...
3
votes
2answers
52 views
Return zero if no record is found
I have a query inside a stored procedure that sums some values inside a table:
SELECT SUM(columnA) FROM my_table WHERE columnB = 1 INTO res;
After this select I subtract res value with an integer ...