Member since
03-27-2023
12
Posts
5
Kudos Received
0
Solutions
09-06-2024
10:21 AM
@Supernova I have tried the same query in my cluster and I got the correct result. +-----------+--------------+ | currency | total_check | +-----------+--------------+ | CAD | 0.0 | | CNH | 0.0 | | AED | 0.0 | | AUD | 0.0 | | CHF | 0.0 | +-----------+--------------+ Can you share the complete table definition please.
... View more
08-07-2024
06:33 AM
After adding a ) to both lines(which Hive didn't like not having), it works for some of the currencies- but others are not adding up properly- ie, they'll double the negative values(when there).
... View more
08-06-2024
10:06 PM
Hi @Supernova Can you try this? SELECT a.currency as currency, SUM(coalesce(a.ColA, 0) + coalesce(a.ColB, 0) + coalesce(a.ColC, 0) + coalesce(b.Col1, 0) + coalesce(b.Col2, 0) + coalesce(b.Col3, 0)) as sales_check FROM db.sales a INNER JOIN db.OTHER_sales b ON a.currency = b.currency WHERE a.DateField = '2024-06-30' AND b.DateField = '2024-06-30' GROUP BY a.currency; Regards, Chethan YM
... View more
05-10-2024
10:39 AM
1 Kudo
Thanks! because i have null values in my data set as well, i used colaesce, and it worked! Your query was the basis though, so thanks again! Query by @nramanaiah that worked for me, as I have null records in the dataset: select Currency, (coalesce(spend_a,0)) + (colaesce(spend_b,0)) + coalesce(spend_c,0)) + coalesce(spend_d,0)) as total_spend from test
... View more
05-03-2023
07:33 AM
Hi all, I have a query that I've found here thanks to @mszurap which I've tweaked and am trying to get working. I have a field called "RunNumber" that identifies if\when data is appended- it can have a value of 1 or 2 usually, but is not limited to 2. I can't use Group By, as you'll see in my query- there are hundreds and thousands of CASE statements. I've tried and cannot seem to get it working in Hive. I get a "..Expression not in GROUP BY key '0'..." Query: SELECT MaxRun = MAX(RunNumber) ,FirstName = SUM(CASE WHEN FirstName IS NULL OR FirstName = 'NULL' OR FirstName = ' ' THEN 1 ELSE 0 END) AS FirstName ,LastName = SUM(CASE WHEN LastName IS NULL OR LastName = 'NULL' OR LastName = ' ' THEN 1 ELSE 0 END) AS LastName ,State = SUM(CASE WHEN State IS NULL OR State = 'NULL' OR State = ' ' THEN 1 ELSE 0 END) AS State FROM Table.Customers WHERE DateOfRecord = '2023-05-01' The output that I'd like to get: MaxRun FirstName LastName State 1 500 750 1000
... View more
Labels:
- Labels:
-
Cloudera Hue
03-29-2023
09:33 AM
1 Kudo
I assume you meant NVL function returns 0 or 1 if a null is found, or the specified expression in the argument - when using Hive. With Impala and NVL2 you would still need to have the outer query to "sum" up all the 1 values what we have mapped from the column value (from their real value to 0 or to 1). It would just be a bit nicer, but no real change.
... View more