Data dodania Pytanie
2017-04-15 21:04 How to find missed ids in my table? »
How to find missed ids in my table? for example right now ids are 1 3 8 my aim is find missed values 2 4 5 6 7 ...
(3) odpowiedzi
2017-04-15 15:04 How does postgres decide whether to use index scan or seq scan? »
explain analyze shows that postgres will use index scanning for my query that fetches rows and performs filtering by date (i.e., 2017-04-14 05:27:51.0...
(2) odpowiedzi
2017-04-15 08:04 Avoid checks for each row, replace query by function? »
I have teams: create table team ( id integer primary key, type text ); Also, I have players: create table player ( id ...
(1) odpowiedzi
2017-04-14 21:04 Using crosstab on a query with a composite key (multiple columns) »
I recently switched from SQL Server to PostgreSQL and trying to find equivalent of pivot function. I am not able to get a desired output using crossta...
(1) odpowiedzi
2017-04-14 20:04 Finding customers that only bought items no one else bought »
Below is a list of orders, is there a way to find the person_id of the customers, that has only bought products no one else has bought? CREATE TABLE ...
(5) odpowiedzi
2017-04-14 17:04 Test if anything was updated in dynamic query »
I need to construct and execute an UPDATE statement dynamically. Then I need to test whether anything was updated at all. My code is as follows: DECL...
(1) odpowiedzi
2017-04-14 13:04 PostgreSQL searching value in inside JSON array »
I want to search element inside JSONB in PostgreSQL here is my JSON CREATE TABLE test AS SELECT jsondata::jsonb FROM ( VALUES ( '{"key1": 1, ...
(2) odpowiedzi
2017-04-13 20:04 SQL add values of rows, if columns are switched »
After a join of the same table, I have a result like this: c1 c2 count A B 5 A C 4 B A 2 B C 2 C A 1 Now, the numbers s...
(4) odpowiedzi
2017-04-13 19:04 What determines the data type that PostgreSQL filters on? »
I'm quite familiar with how IEEE 754 single precision and double precisions data types have their suprizes. I've read the articles on what every compu...
(1) odpowiedzi
2017-04-13 03:04 Print a postgresql table to standard output in python »
I have a table in postgresql named mytable and I need to print the contents of this table from a python application to stdout. I'm currently doing th...
(2) odpowiedzi
2017-04-12 23:04 Concat object to array if object does not exits »
mycolumn is a jsonb type with a default value of an empty array. I would like to update this array if the new value is not already present. select q...
(3) odpowiedzi
2017-04-12 22:04 May I have a join between tables in different databases while using Sequel? »
I'm building an integration software between two different systems. I have Clients in a database, and Groups in another. One Client can be in multiple...
(1) odpowiedzi
2017-04-12 21:04 How can I implement full-text search on a jsonb column with Postgres? »
I have a table that stores a conversation between two people. The data will look something like this: CREATE TABLE foo AS SELECT $$[ { "user":...
(0) odpowiedzi
2017-04-12 16:04 SQLAlchemy sum function with bounds »
In sqlalchemy (postgresql DB), I would like to create a bounded sum function, for lack of a better term. The goal is to create a running total within ...
(2) odpowiedzi
2017-04-12 13:04 Select parents for a list of interesting properties in the parent's children »
I struggled with the title, but let me explain: Let's say I have two data structures: Parent and Child. In my (Scala) code, each Parent instance has ...
(2) odpowiedzi
2017-04-12 13:04 How to read multiple refcursor return by other procedure to another procedure »
i'm having one procedure which returns setof cursors Now i have to call that procedure to another procedure and access the data that return by that p...
(1) odpowiedzi
2017-04-11 22:04 QUERY: where has_many association does not contain specific value »
I have two models Invoice and InvoiceEvent Invoice has many InvoiceEvents InvoiceEvent has a field state I'd like to write a query to find all Invo...
(1) odpowiedzi
2017-04-11 17:04 Exception reentered: When saving polymorphic association »
In my Rails 4.2.7, ruby 2.3.3 App, when I save a particular polymorphic association by saving a nested form it gives stack level too deep error and ra...
(1) odpowiedzi
2017-04-11 16:04 Unique string with at least two differences »
I am looking for a way how to generate unique random (randomly-looking) alphanumeric string with a constraint that each such string has at least two d...
(3) odpowiedzi
2017-04-11 16:04 Query Optimization for the below one: »
I am running this query which fetches close to 100 records. But it is taking nearly 10 mins to accomplish this. Can someone help me in optimizing it i...
(0) odpowiedzi
2017-04-11 03:04 How to fix multi row node-postgres insert - Syntax Error at or near $4 »
I have a multi row node-postgres insert that is giving me issues. It is a parameterized query that uses a Common Table Expression to update a primary...
(1) odpowiedzi
2017-04-11 01:04 Postgres 9.6 - Unique constraint on array of JSONB key for "contains" operator »
We have a Postgres (9.6) table my_table with a row email_address jsonb[] NOT NULL: DROP TABLE my_table; CREATE TABLE my_table (email_address jsonb NO...
(0) odpowiedzi
2017-04-10 20:04 RSPEC - Restore database from file on load »
I have a rails project running rspec for tests and I'd like to restore the test DB from a dump file each time RSPEC is initiated. I tried writing some...
(1) odpowiedzi
2017-04-10 20:04 Row-based security in Postgresql 9.4 based on views for read and write access »
For a system, where the users have full shell access, we want to manage the folders shared between the users via access control lists, using an postgr...
(0) odpowiedzi
2017-04-10 19:04 Ordering queryset by filtered child objects »
I have the following (simplified) data model, see visual representation below the post: Articles, which have Attributes Attributes refer by PK to a ...
(0) odpowiedzi
2017-04-10 15:04 SQL select specific group from table »
I have a table named trades like this: id trade_date trade_price trade_status seller_name 1 2015-01-02 150 op...
(2) odpowiedzi
2017-04-10 10:04 Insert Data in specified column if column value id matches the description of the ID in another table (normalized form) »
In order to do this (in Title Description) it's obvious that it's already a normalized database so an inner join kind of check will be used for sure. ...
(2) odpowiedzi
2017-04-10 09:04 Get text[] value from sql table with FireDAC on Delphi »
On pgAdmin with a simple query 'select * from data' I got only one record containing a field type text[] with value '{"1","2","3"}'. The following sim...
(1) odpowiedzi
2017-04-10 00:04 Postgresql crosstab query with multiple "row name" columns »
I have a table that is a "tall skinny" fact table: CREATE TABLE facts( eff_date timestamp NOT NULL, update_date timestamp NOT NULL, symbo...
(1) odpowiedzi
2017-04-09 22:04 postgres query where values contain backslash »
I'm in the process of migrating a db from MySql to PostgreSql I have one last thing outstanding: In the table steps there is a column overlay_custom_...
(2) odpowiedzi
2017-04-09 18:04 PG::SyntaxError: ERROR: syntax error at or near "USING" »
I'm having trouble migrating my table with Rails. When I run rake db:migrate I get this error. Error PG::SyntaxError: ERROR: syntax error at or nea...
(1) odpowiedzi
2017-04-09 16:04 Optimize Postgres deletion of orphaned records »
Take the following two tables: Table "public.contacts" Column | Type | Modifiers ...
(5) odpowiedzi
2017-04-09 02:04 Why do database checks not raise errors in rspec, but do raise errors in rails console? »
I'm writing a blog app using rails 5.0.2, ruby 2.4.0, and postgresql 9.6.2. I wrote some tests using Rspec to check that the postgres check constraint...
(0) odpowiedzi
2017-04-08 22:04 Multiple INSERTS into one table and many to many table »
I'm trying to develop a Q&A website in PHP using a PostgreSQL database. I have an action to create a page which has a title, body, category and ta...
(1) odpowiedzi
2017-04-08 13:04 Postgres UNACCENT for character with more than 1 diacritic »
The UNACCENT function can strip diacritics off characters. However, in my case, it can only strip characters with 1 diacritic, for e.g. Thành Super...
(1) odpowiedzi