I’m working with a large, complex query. I added a simple date filter to the WHERE clause, and now I get ORA-00936: missing expression Removing the rest of the query, and just selecting id with this single date filter still produces the error – so at least that narrows it down. Looking online, apparently this error is supposed to indicate
Tag: sql
SQL Grand Total row from Multi table Select Query
I have been able to use the below SQL query to give me 4 rows of data SELECT ‘Sales Order ‘ as Type, Format(Sum(T1.C_NetAmountLessDiscount), ‘#.00’) As NetAmount, Format(Sum(T1.C_MarginAmount), ‘#….
group by issue in sql
i’m trying to get in a new column the sessions who are between 08:00 and 18:00. You can see my last CASE in the CTE. For each date there should be a new column “TotalRestrictedSessions” which indicate how many session were on that particular date. If there are none, in this case i have to write 0. I suspect that
SQL request for a JSON file
I am using node-red and influxDB with it. Basically I am running node-red (which execute a python code), with node-red I am getting a data from gauge strain cell, and I have them with a json format as …
Query for array values within jsonb column
I have a jsonb column called chores in my work table with data looking something like this: [{“task”: “feed_dog”, “value”: “Daily”},{“task”: “mop_floor”, “value”: “Weekly”] There could be zero to dozens of tasks in the chores array for each user. How can I query by task name? For example, pull all records where at least one task is feed_dog. SELECT chores->>’task’
Most performant way to filter on multiple values in multiple columns?
I have an application where the user can retrieve a list. The user is allowed to add certain filters. For example: Articles: 123, 456, 789 CustomerGroups: 1, 2, 3, 4, 5 Customers: null ArticleGroups: null … When a filter is empty (or null), the query must ignore that filter. What is the most performant way to build your query so
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens – help needed
I’ve tried making a website which has a database connected to it and I’m getting the error message below SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens This is my PHP code that I have written below Answer It took me a while to find, but I believe that PDO::prepare passes the named parameters
Simple SQL query returning null value
I just started studying SQL queries. I am practicing on this site: https://www.techonthenet.com/sql/joins_try_sql.php I want to find: “the name of the employee with the highest salary for every department”. My query is: And I get null value for first_name : I understand that the problem is due to the group by expressions. But how can I solve this? Tables: Answer
Athena geospatial SQL joins never complete
A very basic geospatial join, based on this example, times out every time. The table polygons contains 340K polygons, while points contains 5K rows with latitude/longitude pairs (and an ID). Both are single .csv files in S3. Query: The SQL query above never completes in the default 30-minute Athena query time limit. I’ve found vanilla Athena queries on large-ish data
How can I optimise COUNT with GROUPBY mysql query?
I have 5M records in eus table and 121 records in es table. I am doing a left join but the COUNT query is making my query very slow. How can I optimize this? public static function …