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…
Tag: sql
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…
How do I parameterize table & column in a Postgres-custom-function, selecting PK if value exists, otherwise insert it and return PK anyways?
Trying to do what I specified in the title, I already got the upsert-functionalities working, however when I try to parameterize it, I’m just out of my depth and can’t debug it. My query: now when I try to use the function, I get: What puzzles me about this is the fact that this syntax works fine …
How to select rows from table when a column repeats?
I have this table (REGIONS) with this sample values: Id Cod1 Cod2 Payed 1 0001 000A NULL 2 0001 000B YES 3 0001 000B YES 4 0001 000C NULL 5 0001 000C YELL 6 0001 000D NULL 7 0002 000A YES 8 0002 000C NULL 9 0002 000C NULL 10 0002 000C YES 11 0003 000C YES 12 0004 000C
Get previous value of current row in select
I am calculating value based on value in previous row. I used LAG for getting value from previous row and it works well for first two but not for next rows. Let me elaborate my scenario if row is first then I am taking Open_HA same as O column. But for next rows I am taking previous row Open_HA and
Get table name without schema
There is a string that could be a table name with ANY schema, not necessarily dbo. How do I get the table name only from the string without knowing the schema? E.g. from ‘dbo.MyTable’ I would need to extract ‘MyTable’. Answer PARSENAME can be used for this:
Duplicate a row based in a column that has 2 values in spark sql
I have a temporary view that looks like this. What I want is to duplicate a row by adding an ‘All’ value to Activity Expecting result would be: I tried to create it through Zeppelin, but I am not able to update a view. Is there any way to do it please ? I can only use SQL unfortunately Thanks
SQLAlchemy group by day in timestamp column
I have an ORM (Model) defined in SQLAlchemy as below: I’m planning to get the sum of all views in each day and tried to group the results based on their end_to. I have used the following query in sqlalchemy: But this query throws this error: I am using the timestamp in my model and I don’t plan to…