I want to convert my @PostgreSQL, CTE Query, into Normal Query because the cte function is mainly used in data warehouse SQL and not efficient for Postgres production DBS. So, need help in converting …
Tag: sql
Pyodbc and AWS Lambda
I have a fairly simple SQL query that’s taking forever to run in my Lambda function and I don’t know why. I know OR statements can be a killer in SQL, but in my database editor, it runs in about 800ms. Why would it take longer in a Lambda function? I’m using cursor.execute() and passing the …
SQL – I need help How to COUNT all sales by month within a year
I can’t figure out a way to COUNT al transactions by month each YEAR on a single query. I figured out a way but for one month at a time, there’s a lot of data (time consuming) this is the table i want to have something like this thank you Answer here is how you can do it , using
sql that finds records within 3 days of a condition being met
I am trying to find all records that exist within a date range prior to an event occurring. In my table below, I want to pull all records that are 3 days or less from when the switch field changes from 0 to 1, ordered by date, partitioned by product. My solution does not work, it includes the first record
Microsoft Access can’t append all the records in the append query due to a type conversion failure
Why am I getting a type conversion error? Here is the insert query: Here is the query where I created the Products table: I tried inserting the BarcodeID with and without single quotation marks to no avail. Any idea what the problem is? Answer Posted from my comments above with code for table: You are using I…
SQL : Get the duration between start DateTime and End DateTime from Table entries
I have a SQL table which has entries of machine start and end time (DateTime) with duration of machine running. Given a start DateTime and End DateTime I want to calculate the duration for which machine was running. DB is SQL and Code is in C#. Note: THere might be some duration when the machine is not runnin…
Mysql / Maridb Python Connector is not loading data into table
The code checks if there is a table with the same name in the db and then potentially drops it, creates a new table and loads the data of the csv file into the table. When executing the code it seems like everything is working but when going in the mariadb command prompt the created table is empty even though
Truncate a column that is the result of CONCAT function?
I’m trying to truncate a column that I have created in my query to display only 15 characters, however I don’t know how to. In a table (yes), in a query (no). How would I write my code to do this? …
Extract a desired character from an alphanumeric column using concise REGEX in Oracle SQL
I am going through a “clean-up” process of a character column that holds employee rankings that should have a single character: 0-5 or M or U but instead it has up to 3 characters that are either numeric, alpha or alphanumeric. I spent the better part of two days researching online (Regex, Stack o…
SQLServerException: No column name was specified for column 1 of ‘bounds’
I am trying to run the following code. The idea is to obtains lower and upper bound of source table, based on a given ID column. However, what I am getting is: And I am not really sure what the issue could be. Answer I haven’t used Scala or Databricks – but I do use SQL Server so my answer