Why do these two results dont return the same results? Can anyone explain why? (addtime is datetime type.) Answer This does not do what you want: Unquoted 2020-10-10 is an arithmetic operation, which returns integer value 2000. You are then asking MySQL to compare it with a date, so it tries to convert the in…
Create a PostgreSQL view from a unique list of exploded data
When I make this request: I get results like this: Each line has values separated with / (space, slash, space). How to create a view with a list of unique values with count ? Answer You can split the string to rows with regexp_split_to_table() in a lateral join, then aggregate: Demo on DB Fiddle: val | cnt :&…
mysql – Search for a key within inconsistent json structure
I know of the functions such as: JSON_SEARCH() and JSON_EXTRACT() etc. This issue is that I am searching for a key in a json string that is not standardized. for example: and the results could be something like this: so in this example I want to get john doe with the acctNum of 123. but, also, the location of…
how to count all rows are approved in sql?
I have this line data, where it also shows the status: approved, in progress, not yet started. I need to count how many lines are ALL APROVED based on the line colors. the data is similar to this: the query should show that there is only color (which is green) that all the status are approved, because red sti…
Dynamic columns from two tables
i need some help. I would like to combine two tables in sql with dynamical columns. Here my thoughts: Table one: Example Table jrincidents Table two: Example Table jrusers reporting like i don’t know how to dynamically add the steplabels from table jrincidents as columns of jrusers if where processname …
How can I group a joined query with linq
I’m trying to produce a data set for a graph that would get me the same result as the following SQL query: But if I try to translate it into a linq query, I can’t get the same result, I either don’t have access to one or the other side of the junction, or I get a yearly total of
Finding a phone number by entering a string SQL
I want to find the phone number in the database by entry into the string, while I wrote this. But if, for example, the number starts with +3 and not only with +7. Any help would be welcome. in SQL I am newbie For example, there is a Users table with a phone column. There are numbers starting at +
The difference between two values from different rows grouping by column
Let’s say there is a table jd_log: What im trying to do, is to find the difference between 2 durations (as duration_diff) for each unique job_name. It is guaranteed, that for each unique job_name there will be no more than 2 entries in the table with such job_name. If there is only 1 entry for specific …
Getting total from query of individual groups
I’ running a query that returns total count of offices per county. and my results look like this: Is there a way to get the total count returned in the same query? Answer If you want it as a column, use a window function: If you want it as an additional row, then use WITH ROLLUP:
SQL Query from getting SubChild to Child to Parent Tables
Good day, I’m trying to create a custom query for my scenario. Here’s the DEMO I created. Suppose I have 2 or more parent tables and this table will be consume by a child table. tblParent1 tblParent2 tblParent3 Then there’s a child table where it consumes these 3 parent tables. tblChild And …