I’ve read just about every question on here that I can find that is referencing getting the latest record from a subquery, but I just can’t work out how to make it work in my situation. I’m creating …
Tag: sql
MySQL: select row only where closest to date has column value
I want to return all rows that were public in May (2019-05), so if a row was turned to draft (and not back to public) at any point before the end of May, I don’t want it. For example: id | post_id | …
How to get the Exact Batch ID from stock table on the basis of Expiry Date?
I want to get the batch id from stock table on the basic of fifo expiry date. How to get it. I write a query it give the exact batch but batch id not accurate. Basically I want to Fetch the batch is …
How do you normalize a table with a multi-valued field?
I want to normalize a staging table into two tables. One of the fields of input data contains multiple values delimited by a semicolon. DATETIME | FILENAME | MULTIVALUEDFIELD 7-22-18 | somefile.txt |…
Count total running events per year with events that range over multiple years
I have a table of events that span over several years. title start_year end_year Event 1 1976 1983 Event 2 1977 2002 Event 3 2018 2019 Event 4 2003 2019 …
Percentage of existence in a group in SQL
Hi I have a requirement of finding the occurrence percentage of specific items in a group. My table is like this Team Objective Status ——————————– Team1 Obj1 …
How can I replace a `’` in a string in SQL?
I have to replace special characters in SQL. My problem is with ‘, because it is used for start and end of string in SQL. I tried: ID = REPLACE(ID, ”’, ”) ID = REPLACE(ID, “‘”, “”) But both not …
How to query MYSQL table to get counts of column occurrence overall and within past year?
I am using MySQL and want to create a query that will count how many times appointments happened per contact_id within the last year, last year, and how many times the occurrence happened overall. …
How to look for missing rows within a group?
Consider the data below. I am trying to find situations where in a specific RequestID, there is an Attempt: 0, but Attempt: 2 is missing. I’ve tried looking for Attempt: 0 with a WHERE predicate …
MySQL Grouping using group_concat and then Group BY
I have a table like this: Basically, I want to group all names and give the count of such groupings like: Since there are 2 users with cooking and cleaning, 1 for washing and 4 for cooking. I am …