I have a transaction table t1 in Hive that looks like this: store_id cust_id zip_code transaction_count spend 1000 100 123 3 50 2000 200 …
Tag: sql
How do I query sql for a latest version of a record in the same date
I am trying to perform a query that returns the value of the last published version. The versions can be named V1, V2, R1_V1, R1_V2, R2_V1, R2_V2 and are published in this order. The first post will always be #null. Not all versions are dependent, I mean, the first version of the day can be registered as R1_V…
Oracle SQL – create select statement which will retrieve every end date of the month but compare the values the day or two after the end of month
Let’s say I have a customer table. I need to create a select statement which will retrieve every end date of the month and compare the values for the amounts respective to the day or two after. If the amount for the day or two is different from the end date of that month, display the recent changed amou…
SQL Select Statement – Automation Anywhere
I am trying to write an SQL select statement where i only extract two columns from a csv which has been connected as a CSV. The select statement query i am using is: Which extracts all data in the table as expected, I wish to only extract data in columns with headers: The below line of code throws a syntax
SQL calculation for the sin() makes division by zero in one PosgreSQL function and don’t do it in another
There is a SQL call consisted of two general parts. The first one works, while the second one is commented out So, the question is why the error occurs only if the second part is commented out. The part where the division occurs are all the same: vs they both should be zero, or none. But only the second one
Get rows with a condition
Each customer can have one or multiple accounts (account_id) How can I get max closed_date for the customers who closed all their accounts and the rest of the active customers?* *active customers are …
How can I pull out the second highest product usage from a SQL Server table?
We have a product usage table for software. It has 4 fields, [product name], [usage month], [users] and [Country]. We must report the data by Country and Product Name for licensing purposes. Our rule …
Return Data based on Column
I am modifying a current query which returns n amount of rows. I would need to return the same amount of rows but with one more column of data. I have two sql tables shown below. Products and Product Attribute Values. When i run this query i get a few 1000 rows back. But when i run this query I
Is table order imporant in mysql when creating relation between them?
I have quite simple question. I am creating database administration tool, where user will be able to create relations between tables, but I am not sure if table order is important when creating relations. For example: I have two tables ‘user'(user_id(INT, PRIMARY KEY), name(VARCHAR), email(VARCHAR)) and…
What do the quotes mean in this SQL Server snippet? (SELECT ” column1, ” column 2)
I’d like to know the purpose of the two single quotes in front of each column. This is in a stored procedure. Thank you for your help! Answer The expression ” is an empty string. So this is using an empty string instead of NULL for “missing” values. I would write this code as: This mig…