Data dodania Pytanie
2017-02-18 20:02 Can SQL CASE return a different number of columns in WHEN clauses? »
Is there a way to SELECT a different number of columns in different WHEN clauses of the same CASE statement? For example SELECT CASE x WHEN is...
(2) odpowiedzi
2017-02-18 20:02 Is it safe to rely on Postgres' deadlock detection for concurrency control? »
I've been running into occasional deadlocks in my application because two transactions which need to update the same rows but in different orders (ex,...
(1) odpowiedzi
2017-02-18 20:02 Passing conditions to ActiveRecord_Relation .order - Rails 4 / Postgres »
I am using STI on a table called Clients. Clients has a boolean attribute called is_additional. How can I call .order on an AR Relation for primary a...
(0) odpowiedzi
2017-02-18 09:02 Is it possible to get query faster? »
I'm new to SQL and need help I have 4 tables: helmet arm +------+---------+-----+--------+ +------+---------+-...
(4) odpowiedzi
2017-02-18 00:02 Convert JSONB Array to Columns »
I have a query that returns a single column containing jsonb objects. Here is an example of some returned rows (jsonb::text for legibility here): [{...
(1) odpowiedzi
2017-02-17 21:02 Django can't connect to Postgres in Docker setup »
I'm setting up an application in Docker that uses Django and Postgres. I'm unable to connect to Postgres from the app. When I run either: docker-com...
(1) odpowiedzi
2017-02-17 19:02 Modify datatype of a field in JSONB in Postgres »
I have a JSONB column with JSON that looks like this: {"id" : "3", "username" : "abcdef"} Is there way to update the JSON to : {"id" : 3, "u...
(2) odpowiedzi
2017-02-17 19:02 Postgres conditional unique constraint »
Pretend I have a users table where users are members of a specific tenant, and their e-mails are uniquely indexed to their tenant, like this: User id...
(2) odpowiedzi
2017-02-17 14:02 Window Function: last_value(ORDER BY ... ASC) same as last_value(ORDER BY ... DESC) »
Sample data CREATE TABLE test (id integer, session_ID integer, value integer) ; INSERT INTO test (id, session_ID, value) VALUES (0, 2, ...
(2) odpowiedzi
2017-02-17 14:02 Removing element from array within object JSONB »
I am attempting to remove an element from my database. The element I want to remove is within a JSON object called playerContainer which contains an a...
(1) odpowiedzi
2017-02-17 08:02 Correct use of cursors for very large result sets in Postgres »
Short version of my question: If I hold a cursor reference to an astronomically huge result set in my client code, would it be ridiculous (i.e. compl...
(3) odpowiedzi
2017-02-17 04:02 Why does PostgreSQL serializable transaction think this as conflict? »
In my understanding PostgreSQL use some kind of monitors to guess if there's a conflict in serializable isolation level. Many examples are about modif...
(2) odpowiedzi
2017-02-16 20:02 How to save 'Yes' or 'No' instead of 'true' or 'false' with Rails check_box form helper? »
I have an object @recipient with attribute responding. Say, I want responding to store "Yes" or "No" via =f.check_box :responding, {}, 'Yes', 'No', wh...
(2) odpowiedzi
2017-02-16 18:02 Confused about the "NEW" keyword in SQL functions »
I'm relatively new to SQL/PostgreSQL and we just started working with triggers and functions/procedures. These are the two relevant tables CREATE TA...
(1) odpowiedzi
2017-02-16 13:02 Update Postgresql table straight from a JSON object »
I use select to_json(host) from host where id=3 to query data from my postgreSQL database the result is like: {"id":3,"project_id":1,"name":"a","m...
(1) odpowiedzi
2017-02-16 12:02 ActiveRecord & Postgresql: Query jsonb attribute »
I have a model Characteristic, with a equivalent attribute which is a jsonb value. ex: characteristic1: id:1 equivalent: {list: ['first', 'second'...
(1) odpowiedzi
2017-02-16 05:02 how can I make hibernate to create tables only if they didn't exists? »
how can I make hibernate to create tables only if they didn't exists? I just set "hibernate.hbm2ddl.auto" to "update" but it is giving er...
(1) odpowiedzi
2017-02-16 05:02 Flattening a nested json[b] array in Postgres »
I have jsonb column feeds with data in the form of this: [{ "id": 99999999, "lang": "pt", "entities": { "urls": [], "media": [{ "...
(2) odpowiedzi
2017-02-15 19:02 Use JSONB for postgres columns other than primary and foreign keys »
I just discovered JSONB for PostgreSQL and was wondering what could go wrong if I used it for all my tables' columns ? That is to say all my tables w...
(1) odpowiedzi
2017-02-15 11:02 DataGrip Postgres SSL error: sun.security.validator.ValidatorException »
DataGrip won't connect to my Postgres instance, but I can connect fine via psql on the terminal: psql -h dbhost.com reps username >Password for us...
(1) odpowiedzi
2017-02-15 08:02 Selecting data from different rows »
I want select the opening balance of the first month and the closing balance of the last month in PostgreSQl then now i the sum of income as total inc...
(1) odpowiedzi
2017-02-14 23:02 Why are the following SQL queries not equivalent? »
SELECT c.cname FROM Customers c WHERE c.age > ALL (SELECT c2.age FROM Customers c2 WHERE c2.type = 'snowboard'); SELECT c.cname FROM Customers ...
(1) odpowiedzi
2017-02-14 20:02 Postgres WITH RECURSIVE CTE: sorting/ordering children by popularity while retaining tree structure (parents always above children) »
I'm building a forum, very much like Reddit/Slashdot, i.e. Unlimited reply nesting levels Popular comments (ordered by likes/votes) will rise to the...
(2) odpowiedzi
2017-02-14 19:02 Appending (pushing) and removing from a JSON array in PostgreSQL 9.5+ »
For versions less than 9.5 see this question I have created a table in PostgreSQL using this: CREATE TEMP TABLE jsontesting AS SELECT id, jsondata...
(1) odpowiedzi
2017-02-14 16:02 Testing Materialized View in Rspec »
Using the Scenic gem I've built an activerecord model backed by a materialized view class MatviewSales < ActiveRecord::Base self.table_name = 'm...
(0) odpowiedzi
2017-02-14 16:02 Postgres index 2 columns with condition »
Given a table of stores (~10k records) and a table of schedules(~200k records), I am trying to create and index for the planner to use, but it ignore...
(2) odpowiedzi
2017-02-14 11:02 Making a partition query, reporting the first NOT NULL occurrence within partition before current row (if any) »
I have a logins table which looks like this: person_id | login_at | points_won -----------+----------------+---------------------- 1 ...
(2) odpowiedzi
2017-02-14 10:02 Create nested json from sql query postgres 9.4 »
I need to get as a result from query fully structured JSON. I can see in postgres that there are some built in functions that may be useful. As an e...
(2) odpowiedzi
2017-02-14 05:02 How to find records where a column value = [given array] in rails »
Setup: Rails + Postgres. I have table A with columns id: int, name: string, address: string, s_array: varchar[], i_array: int[], created_at: dateti...
(3) odpowiedzi
2017-02-13 22:02 Filter strings with regex before casting to numeric »
I have this code (was already there, isn't mine): SELECT a.id_original_contrato AS contrato, ( CASE WHEN d.value~'^\\d+$' THEN d.value::integ...
(2) odpowiedzi
2017-02-13 22:02 Show Percentages for Week and Year »
I have this sql syntax, which works great. It shows the count of sources utilized to get to us. I want the number to be shown in percentages (out of 1...
(1) odpowiedzi
2017-02-13 16:02 how to create a table in SQLAlchemy using Postgres? »
Hi I'm trying to create a Table using SQLAlchemy in Postgres, it process all well but the table is not created in my Postgres server. My models.py fi...
(1) odpowiedzi
2017-02-13 14:02 Optimize a NULL / NOT NULL flags PostgreSQL query »
I am trying to get one record that contains boolean flags: true if a column in specific result set has at least one NOT NULL value and false if all th...
(3) odpowiedzi
2017-02-13 07:02 Comma separated values with all rows from a table »
I have a Services table with three columns. Service sr_id lang alias 1 EN A 1 PA B 1 HI C 2 EN D 2 HI E Now, I...
(2) odpowiedzi
2017-02-12 22:02 How to select the first part of string that has a match in list of values in PostreSQL? »
I'm working with medical data and I want to find the primary diagnosis given to certain patient. The diagnoses are all in one column as a comma separ...
(3) odpowiedzi