Lots of questions about the construction of SQL queries are asked on Stack Overflow every day, each competing for attention with the dozens of others that are asked. Those that take the trouble to provide minimal, reproducible examples are far more likely to be answered quickly, and accurately.
It's easy to provide a sample data set. It doesn't have to be real data. It just has to fairly reflect the nature of the problem at hand.
Similarly for the schema itself; to solve your specific problem, we don't generally need to see the whole thing—and we definitely don't need to see some dull entity relationship diagram, or scrappy screen captures of Excel spreadsheets. Instead, only the relevant tables and a dozen thoughtfully chosen rows of data is usually enough to understand what should be included and/or excluded from a desired result set.
So, it's nice to see three things:
CREATEandINSERTstatements (and/or an sqlfiddle or rextester or db-fiddle or db<>fiddle) for all relevant tables, so that we can more easily replicate the problem. Ideally, these should clearly identify PRIMARY/UNIQUE KEYS and incorporate the proper use of data types—so dates are properly formatted (YYYY-MM-DD).You can also use anAn ASCII data table generator tool to easily generate formattedcan assist you with the construction of ASCII data tables which you can use in your question. Somesome of the websites mentioned above can then convert those ASCII tables directly into
CREATE TABLEandINSERTstatements for multiple database systems like MySQL, PostgreSQL or SQL Server (MSSQL).A desired result set that corresponds with the information provided in step 1.
Your best efforts to date. These don't have to be stellar pieces of cogent analysis. We just like to see that you've taken some steps towards attempting to solve the problem for yourself. It also helps us to know where to start in our explanation.