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 events, but the original
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 after import: Data truncated for column… my_date sets to 0000-00-00, even with
MySQL – Show the restaurant name and items where price is over a certain value
I have two tables: I am trying to get the restaurnat name, item name and price where all the restaurants’ items have a price higher than 10. Examaple result: restaurant item price The King Fry item 1 12.30 THe King Fry item 2 13.00 The King Fry item 3 10.60 All the items listed on their menu are > 10
Call stored procedure in Snowflake query
I have a stored procedure, called SP_CALC_BUCKET, defined. I can call it like so: and this works, and returns the result I expect. However, if I try to call this stored procedure for each row returned from a SELECT statement: I get the following error: Unknown user-defined function SP_CALC_BUCKET Clearly, the Syntax is informing Snowflake that it should look for
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 from the
How to return rows containing decimals in a range
I have the following table: Rows Decimals First 1.1.1.3.2 Second 16.1.1.1.89.1 Third 3.1.1.1.177.2 Fourth 1.1.1.1.178.3 I only want to return the rows where the second to last decimal is between 0.7 to 0.94 (inclusive), but all the other numbers can contain any value. For the above table, this would be only the second row. How can I specify my query
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 average on the table,
What should I do to join two columns with different name but has the same data type, so that I can get something I need from one of the table?
I have two table, [table a] and [table b]. So basically, I need work_week from [table a] therefore I want to join the columns together, shift_begin_datetime from [table a] and shift_start_datetime from [table b] as both of them have the same data type but they have different name. I want both of the column to be renamed as shift_start_dt and
Fatal error: Uncaught mysqli_sql_exception: Unknown database ‘test_db’. I keep getting this error even though I programatically created the database
Here is the code I am not sure what is going on as I am sure i made no errors while typing. As it keeps showing me that there is an unknown database despite the fact i made a CREATE DATABASE statement. I do not know if there is something else i need to do but by all measures the
INNER JOIN with aggregate functions in my SELECT
I’m trying to join a new column to my current query that uses aggregate functions. I create this column with a new query that also uses an aggregate function from a different table but I’m not sure if a JOIN will work for me since I need to join it to its respective row. TABLE A (employees that are enrolled