I really appreciate all of you for your help. We are in the process of standardizing the addresses of our customers. I have a main customer table which contains the customers data, the address field …
Query to find active days per year to find revenue per user per year
I have 2 dimension tables and 1 fact table as follows: user_dim user_id user_name user_joining_date 1 Steve 2013-01-04 2 Adam 2012-11-01 3 John 2013-05-05 4 Tony 2012-01-01 5 Dan 2010-01-01 6 …
How to automate a sql script in snowflake
I have a SQL script that transforms data for various tables in snowflake. I need to run this SQL code daily and I want to automate it somehow. I thought I could automate the SQL with ‘tasks’ in snowflake but ‘tasks’ are unable to run more than one single SQL statement and my code contains a multitude of SQL statements.
How to count by unique id values that contain specific text in GoogleSpreadsheet
For this question, I understand that SQL could be used via =query(“some code”), it is completely valid this way, but if a simpler way exists, better. I want to count in GoogleSpreadsheet all …
How to remove duplicates out of the UNION but ignore one column
Consider the following table of data: FirstName LastName Department Steve Colton Accounting Stacy Beckham Finance Mary Messi Finance Steve Colton Finance Michael Gretsky Finance As you can see Steve Colton is in both Accounting and the Finance departments. I want a query that should return Steve just once. I can do the following which works but seems like more code
how would I limit the results to only one address based on a preference
Some of the donor ID’s have multiple mailing addresses, and I just need to select only the first one for each donor, and if there is no mailing address tied to a donor ID, then I need to pull a billing address, and if no billing address, then shipping address. but only show one address Answer You could do something
WHERE clause expression references [casted timestamp to date column] which is neither grouped nor aggregated at
This query should sum up all the records by Error_Type (nested) and by Application(nested) in the Failed_Record_Count column. Total_Record_Count column should sum up all the records from the table(excluding unnested tables). However, an error referencing to a.timestamp in the subquery is said to be neither grouped nor aggregated. I noticed that when removing the “DATE” function from the select list,
CosmosDB count using OrderBy multiple conditions
I am using Azure CosmosDB, the model contains Id, and creationTime properties. What I am trying to do is count entries within time interval. I looked how to achieve it using LINQ but could not find a solution. What I used than is SQL. This is what I tried: Bare in mind the values i showed are for display purposes.
Select all rows which match a condition dependent on over rows
Let’s assume I have a table T with the columns X, Y, Z where Z is some comparable value (I have to make it work on a PostgreSQL database but a solution that additionally supports oracle would be even nicer). What I want to achieve is best described by the following, sadly invalid query: This is invalid since window function
How to short a sql case query that uses between
Hi have this sql query: How can I short this query so I don’t use a lot of case statements? Answer You can try using mod subtracting the remainder t from you value by division for 1000 or as suggested by @DM you can also use the difference should be the same .. both involve function .. but there are