I have a table like so: I’m trying to get the last date when the account was active, not counting today. If the id is not present on today’s date, it is not included in the final table. So for the case of id 1, that would be 2022-04-02, and for id 2, it would be 2022-04-01 I can do
Tag: hql
Replace values based on JOIN
Let’s say I have two data sets A and B After left join I should get FALSE value for Y in table A as it doesn’t have it in table B Answer Using your approach, if you intend to get a value of FALSE if the value doesn’t exist you can check for NULL in the name. The example below
How records can be retrieved based on three conditions?
I’m new to HQL. I need to fetch all the records from table A based on the following 2 condition using HQL/SQL query: Person ID which satisfies both these conditions “(Music < 100) and (Dance !...
Select using WHERE if any exist, else don’t use WHERE
I want to select from a table where column = ‘n’. If the result has 0 rows, I want to remove that conditional. Some pseudo-sql might be: I will only be using the first row in either result, so it would also be acceptable to somehow sort the result such that rows where COL_B = ‘mystring’ appear at the top.
Case condition in hql
What I’m trying to achieve with this query is: always do the “mother” conditional, but if there isn’t mother, then do the “dad” conditional, is this posible? Answer This query: will try to join first by matching the column idMother to :idMother. If this is not possible then a match of idFather to :idFather will be used, if it exists.
Percent change with grouping variables
I have four grouping variables Month, State,County, City. In addition I have the metric column sales which can be null I would like to calculate the percent change of sales per month for each City. My solution would have the same grouping but with the sales column replaced by percent change for each month in calendar year 2019. Any help
Hive – How to read a column from a table which is of type list
I have a Hive table named customer, which has a column named cust_id of list type, with following values: cust_id Now I want to read only this specific column cust_id in my select query, which can give all these list values as following separate values of this column cust_id: Basically I want to fetch all the values of cust_id from
[21000][1242] Subquery returns more than 1 row
My Query: Here I get the error – [21000][1242] Subquery returns more than 1 row By the method of exceptions, I determined that the error in this query string: How to make the correct request so that there is no this error? Thank! Answer Two common ways are aggregation and limiting: However, those are really just hacks to get around
How to compare timestamp in HIBERNATE query?
I have one value of timestamp that I retrieve from the database and then compare it with the current timestamp. I actually want to retrieve data of people who have been logged in for the last two hours. Unfortunately, I am facing this error. please help me, guys. I shall be thankful to you. I have stuck in this code.
How to take union and write into the same table?
I have a table A with columns (x, y, z) and I have another table B with columns (x, y, z), basically the same schema. I want to add those rows from B into A, which do not already exist in A, basically after the operation the union of A and B exist in table A. How do I do