Skip to content

What does the following SQL query do?

The drawing logs at that the company I work for use are written in MS Access VBA. The original code was written 15+ years ago by someone else, and we’re now running into errors with the reporting functionality that we can’t find a solution for. The query I’m having an issue with is the follo…

Get fill rates in another table – SQL Server

I am trying to create a script to calculate the fill rates for each column in a table Data_table and insert it into a second table Metadata_table. The Data_table has 30 columns in it, and some columns have 100% data in them, and some have less than 100% (due to nulls). My code to calculate the fill rate looks…

Return sums even if no data exist in given day

I have a table with amounts only on some days, e.g.: How can I query the data and get: I tried like: But still it doesn’t return 0s for days without data, any ideas? Answer In Access, you can create a series of dates between the first and the last date, and then create an outer join to your summed

Nested queries in SQL

I am trying to combine 2 queries using a nested query. The first one is this: SELECT DISTINCT( de.MCH_CODE) AS Mach, md.MAT_CODE as ShortenCode, de.TIME as start_time FROM table1 AS de JOIN …

SQL: Split time interval into intersects of one hour

I am new to SQL, where I am trying to split time intervals into multiple rows of one hour, together with an indicator of how many minutes the interval overlaps each hour. My data: What I would like: What would be the easiest/fastest way to do this? Answer Try something like this: demo Result for sample data

Split a column in SELECT

I’m trying to get all records where I have a column concatenated with a :. The data stored in table as like this: I want to get below results by removing :extra from column in query: I’m not sure what should I do with my above query. Answer For SQL Server, you would do: You can find the columns us…