I’m writing a query on data with a ‘provider_id’ column. The data is mostly unique except for some entries with all columns but ‘provider_id’ being unique. Most of the values for provider_id are 1 but …
Tag: postgresql
Using generate_serires with partition by generate triple duplicate row
I have a table which look like this: dt type —————————– 2019-07-01 10:00:00 A 2019-07-01 10:15:00 A 2019-07-01 11:00:00 A 2019-07-01 08:30:00 …
Sum variables when condition is met in sql
I have a table mes_transaction where I have variable dc – it’s either DEBIT or CREDIT. I am writing a sql procedure for another table(if I can say so). In the other table mes_aggregated_trx I have trx_amt – transaction amount variable. Basically what I need to do is to write a procedure that would sum trx_amt in mes_aggregated_trx based on
Retrieve Records of the Last Consecutive Dates in PostgreSQL
Edit Sorry for being unclear in the first post. If the item appears only once, it should also be included. Please, check updated sample table… I have a table of record of sales of each item per day….
Pad row with default if values not found PostgresSQL
I wanted to return the last 7 days of user_activity, but for those empty days I want to add 0 as value Say I have this table actions | id | date ———————— 67 | 123 | 2019-07-…
SQL : Choose three stock tickers which have complete data between 2012 and 2017 in the Quandl Wiki data set
I have a custom_calendar table like this: [1] https://imgur.com/YLUix5y “custom calendar image” And I have a stocks market table ( v_eod_quotes_2012_2017 ) which looks like this: [2] https://imgur.com/a/Ff7Gkw1 “v_eod_quotes_2012_2017” As I mention in the question, I need to find out which three stock market symbols has complete data i.e data for every day in between 2012 and 2017. I have
Check if repeated row has value in one attribute in any of the rows
I have a table that looks like this: ID | Position ————– 1 | 0 1 | 3 1 | 5 2 | 1 2 | 2 3 | 1 3 | 5 I would like to extract for each ID if it contains a …
find all entities by nested list that don’t have some value
I have tables NighClub, Visitor and Visitors_NighClub (many to many). I need to get all night clubs which DONT HAVE certain Visitor. To get NightClubs which HAVE certain Visitor I do like this: SELECT …
How to insert data into a String array in postgres stored procedure
I have a pseudo stored procedure as given below: CREATE OR REPLACE FUNCTION get_data() RETURNS void AS $$ DECLARE rec_new RECORD; querystring TEXT[]; cursor_file CURSOR FOR …
When should I split my table for faster lookup?
I have a Postgres table with 500k rows that are only read (a lot, by multiple users). I was wondering if splitting the database in two by, let’s say “date of birth” of the rows, would be more …