I have a strange problem: There is a price in a JSON column in a table and the following statements give different results while they should give the same thing: Just to check I also added a JSON_EXTRACT(item.price_details, “$.shipping.price”) AS shipprice Result: MariaDB version: mariadb Ver 15.1…
Tag: sql
MYSQL Error #1415 on Function Creation: Not allowed to return a result set from a function
Trying to create a conditional-based function that will return a result. I don’t if it’s the way I am setting the result value that is causing the error? Making MySQL throw the error code 1415 Not allowed to return a result set from a function. Answer your code has multiple problems, but the bgges…
PostgreSQL -Assign Unique ID to each groups of records, based on a condition
I am trying to group records of a table, based on a condition, and then asing in a new column a simple integer ID for each group obtained from where the condition is met. ID TMSTP CAT_TYPE TELEGRAMMZAEHLER 1 2022-05-03 20:52:02 32 5004 2 2022-05-03 20:51:34 32 5002 3 2022-05-03 20:51:34 32 5001 4 2022-05-03 2…
How do I see the COUNT results for only the top values in the table and not the entire table in sql
I am creating a Database for my utility bills in SSMS18, and I am trying to retrieve the count for the occurrence of a specific month in the top 10 months with the highest bills. How do I restrict the COUNT feature to only count the top number of rows? Table design I can limit the results by adding a
How to select multiple rows of the same user that satisfies some condition in SQL?
A have the following data I want to select all users who have visited both Spain and France. How can I do that in MySQL? Answer Something like the following should suffice:
Generate random pairs SQL
Suppose we have these two tables. TABLE1: TABLE_2: I want to pair all rows of TABLE_1 with some random columns from TABLE_2 where each pair is gonna have a random amount of distinct rows from TABLE_2 (range 1,2,3) An output could be: Answer did the thing for me.
How do I select floating-point infinity literals from a SQLite database?
I have a SQLite database with a table named measurements, which contains some experimental data measured by a power meter. They’re stored as data type REAL in a field named power_dbm. In some measurements, the readings can be off the scale, the meter cannot obtain a reading due to overrange or underrang…
improve sql query with 2 EXISTS sub queries
I have this query (mysql): It runs multiple times on app start. It takes more than 10 seconds (all of them). I have indexes on: balance_histories table: budget_item_id, family_id (tried also payment_date) budget_lines table: family_id, budget_id, budget_item_id How can I improve the speed? Query or maybe mysq…
How to Exclude Record Based on Multiple Fields where Records May Share Values
I have two tables of addresses. They are formatted very similarly, to [main] table also has the customer name The shipto table has many addresses for each main customer, and many times the main addresses is also listed as a shipto. I do not want to include that main address in my results but I can’t get…
Select horses with logical operators [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 9 m…