Let’s say I have col1 col2 a c b d and I want to have only one column, I’d do and get col1 a b c d But now let’s say I have 100 columns (all strings, same data type), what’s the best way to add all the columns together without doing a union all for all the columns? I
Handle pg_error on generated columns
I have a table that consists of some PostGIS related data. These data are generated automatically on INSERT or UPDATE. Sometimes the data provided on the polygon column might not fit the generation function and cause an error. I wanted to handle this error and set a default value when it fail. — Last re…
How to pull rows from a SQL table until quotas for multiple columns are met?
I’ve been able to find a few examples of questions similar to this one, but most only involve a single column being checked. SQL Select until Quantity Met Select rows until condition met I have a large table representing facilities, with columns for each type of resource available and the number of thos…
MySQL self join but in the same row
I have this table: date sku note 11/12 123 note 11/13 123 note 11/12 456 note 11/13 456 note 11/12 789 note 11/13 789 note (Note is random) And I want the result to return this: date sku note sku note sku note 11/12 123 note 456 note 789 note 11/13 123 note 456 note 789 note I tried self
MySQL substring to self join
I’m defining the relationship between the two tables using a join table. I want to arrange them in the order of many overlapping things. Currently, we are using subquery, is there a way to get the …
postgresql combine 2 select from 2 different tables
Hello i need to run a query with 2 select statements, one with an avg calculation and grouped by name and the other select, looking for that name in other table, and get some columns and do a JOIN to merge both and only left one column “name” on it. The first table its this: The second table its l…
Redshift: Support for concurrent inserts in the same table
I have a lambda code that fires some insert queries to the same Table concurrently through redshift data api. Considering such queries will be fired concurrently, does Redshift apply a lock to the Table for each insert? Or does it allow parallel insert queries in the same table? I’m asking because postg…
sql query with avg price per day and group by day
I got this table and this query: I need to get only one price, with avg I think, and grouped by day, something like this Thanks for your help Answer
Getting a syntax error when trying to execute this SQL query in Python
I’m trying to get the script to automatically set the query start time as 6am yesterday (and will set the end time as 6am today once I figure out the Start time error) but I am getting a syntax error (102, b”Incorrect syntax near ’06’.DB-Lib error message 20018, severity 15:nGeneral SQ…
Getting a not valid month and need to insert records in incremental manner
The problem which I am facing: I need to convert timestamp to date and then insert it into the deligate_details_trans for the completed_date column of the deligate_details_main table. When I am converting it is giving ORA-01843: not a valid month error. Currently, deligate_details_main has 3 rows that are goi…