Skip to content

Window Function for First Instance in Repeating Time Periods

I’m trying to translate the logic below into one or more SQL statements: Find the first occurrence of a given event for a user If the user has any additional events on that day or 30 days after, exclude those events. Keep only the first event. 30 days after the original event, you may consider new event…

How can i change SQL date format to: 12th Jun 2021. (as example)

So, I’m trying to insert data from .csv file, but because of the date format I’m using – import causes it to set to 00-00-0000 import settings: format – CSV using load data (otherwise it causing errors and failing to import) Specific format options: none Errors I’m receiving afte…

How do I get column names of two tables at a time

How do I get the column name of two tables in a single query ? This works for single table. But if I try This throws error. Answer Different queries will be put together using UNION ALL (or UNION only if it’s necessary to exclude identic values which appear in both queries): Since you want to get data f…

How to do conditional aggregate based on values of another column?

I have a table called device_data that looks like below It basically stores the packet drops, jitter, latency on a minute basis. Now there is another column called alert that holds the value HIGH, MEDIUM and LOW based on a threshold and holds empty string if the threshold is not met. Now I do an hourly averag…