Skip to content

Data query to keep the common data

I have a table Table 1 : It the final table contains all data . ID and IDS are composite key table 2 : Its a pre final table which will upcoming data with incomplete information EXPECTED RESULT : Some IDs (ID+IDS) are in Table 1 and some are in Table 2 . I need to compare the data of

Hive trunc date format issues

I am trying to convert GP to Hive migration logic but below statement giving the wrong output while execute query: output for GP : 2021-12-31 similar if we converted Hive query out put if Hive query : 2022-01-02 i could see the difference of the date. please help me. Thanks Answer You are subtracting interval…

DB2 LUW MERGE using same table to update a different row

My table data looks like this My poorly attempted SQL is this… It is updating all rows in the table. I do not want this. How can I make it ONLY update the 1 latest PRINTED row which has an empty PDF_FILE ? Answer The idea is to enumerate target rows and update only the 1-st one.

Sort COUNT(CASE WHEN) results

I am taking a database of statuses and creating the statuses as columns in order to count how many records from a network exist in each status. I’d love to sort the results based on the Partnered column DESC, but I can’t figure out how or where to do that?? Here’s my code: Here are my result…

Subtract row values of 2 columns within same table in SQL query

I’m trying to subtract the row values of 2 different columns in the same table. Table schema I want to subtract com – refund if support column is not NULL and status = 1 Output should be like as Answer Try this: The ‘as output’ names the column in your result set. The where statement f…

use quotes in sql query node.js

I have my query like so: but when I insert the query into my database (I am storing the query for analytical purposes), it fails because of the quotes. how can I fix this? I tried converting thequery to toString(), but that was a useless attempt. Any other ideas? edit: error i am recieving is: Answer This is …

Using IF in PostgreSQL

I need to check (here for an example) if the average earnings of DE workers are higher than IT workers. I tried using but it doesn’t seem to work. Is there any way to do this in PostgresSQL (I am using version 14) first_name last_name country earnings Andrea Pfeiffer DE 800 Eufrosina Marchesi IT 2975 El…