Skip to content

Tag: sql

Query did not return a unique result

This is the query I have written: This is the output I am getting from the database: id versions 101 0.0 101 1.0 101 2.0 101 3.0 In my application, I am storing this result in but it gives an error saying “query did not return a unique result” How can I store this result? which data structure coul…

Count all the entity between periods – SQL Server

I want to count all the entities that created between August 1 until May 31 for each year. (academic year) I am successful counting it monthly, but it’s not good enough: Can someone help me with this? Thanks. Answer you can try this : Explanation : when the month is small than 6 then it’s part of …

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.