I have two queries that retrieve records from 2 different tables that are almost alike and I need to merge them together. Both have created_date which is of type datetime and I’m casting this column to date because I want to group and order them by date only, I don’t need the time. First query: Se…
Tag: mysql
Incorrect parameter count in the call to native function ‘str_to_date’
There is a table tab1: |creation_date | acc_num | status| |——————-|———————|——-| |31.03.2021 07:43:43| 11111111111111111111| deny | |31.03.2021 07:43:43| …
Calculate the number of unique strings with the date, with a possible error
In the select, I get rows from the table with time in the format TIMESTAMP. I want to count unique rows, BUT with a possible error of 1 second. In the example below, for example, 3 unique records (1 …
Determine persistent growth in value during a specific time range
Given the following data set example, how should I structure my SQL query to determine if the value has gradually grown day-by-day given a time range in the query for a specific user_id by returning a …
Determine growth in value in a specific time range
Given the following data set example, how should I structure my SQL query in order to determine if the value has grown over time (given a time range in the query) for a specific UserId by returning either a positive/negative growth percentage result or a true/false result UserId timestamp value 1 1617711825 3…
MySQL – why limit varchar
In MySQL you have to set a limit if you are to use a varchar. Does this limit only exist to make it less likely for devs to accidentally store too much data or is there any other reason (i.e. more effcient access) to set it to a low value? Answer VARCHAR columns are represented in the database with a
mysql query error: SQL sum with condition
This is my code: select assignedstfid, staffname, staffsymbol, SUM(case where bookingstarttime > ‘2021-03-31’ then TIMESTAMPDIFF (minute, bookingstarttime, bookingendtime) else 0 end) as …
Analysis of the completeness of the availability of products from the ClickHouse SQL database
Documentation: https://clickhouse.tech/docs/en/ Goal: 85% of the brand’s product range should be available for purchase Calculate the number of products of each brand by availability (maxItems > 0)…
Interval to previous row
I would like to get the interval between the rows in my table. When I use this query I get seconds from previous timestamp. But the result is only right when two timestamps is in the same minute. …
MySQL Workbench – SELECT is not valid at this position with this server version when using CASE WHEN statement [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 11 months ago. Improve this question When implementing a basic CASE WHEN statement in MySQL Workbench, I…