I am designing database using Microsoft Access for capacity management. I have different types of equipment and need to track the power usage by every month. For instance, I have HVAC system and Chiller System. Withing each system there are different equipments like AHU_1, AHU_2 ,AHU_3, MAU_1, MAU_2 and etc i…
Set ALL Values of PostgreSQL column to X
I have a PostgreSQL database table with same sample data whose schema is shown below. | UserId | XP | Level | ———————– | 123456 | 55 | 12 | | 134156 | 45 | 4 | | 526083 | 39 | 5 …
How to compare within a partition across all possible values in MySql?
I am trying to compare values for each user per each retailer transaction. This is the input example table: Now, I want to compare for each distinct user for the same retailer if the amount spent was within 30% across all purchases. Let’s say that the amount spent of the first and second transaction is …
java.sql.SQLSyntaxErrorException: ORA-00947: not enough values
System.out.println(“Enter the code: “); Code=input.next(); System.out.println(“Enter the title: “); Title=input.next(); System.out.println(“Enter the semster: “); Semester=…
Fill in missing dates and grouping problem
I have a table with Case records with CaseId, UserId, Opened date, Closed date etc value. For reporting I need to have a result table with all users by continuous months with number of case still …
UNION two tables with conditions from the first
I have a union on the same table [MyTable] so I can select certain values as the top 5, the logic of which I’m excluding here to simplify the question (I hope): The first table I alias as tbl1 – can I reference this alias somehow after the UNION statement so that I can exclude the results from it?…
SQL query to get Net Salse by every month
I’m looking for a query to get monthly net sales I tried this far but I couldn’t get what I want. this is my Order Table +———-+———–+——–+————+—————+————-+—…
What is cardinality() in presto sql?
Does anyone know the purpose of cardinality() function in sql? How does it work with unnest function? SELECT story_id, cardinality(image_tags) AS image_tags, cardinality(comment_tags) as …
Compare dates between two dates at specific positions
Given the following sample records within the table: MY_DATES, using Oracle SQL and/or PL/SQL, I need to always take the first DATE_REGISTERED in this table, i.e. 26/10/2019 and then advance to the third DATE_REGISTERED record/value, i.e. 2/02/2020 and check if the difference is greater than 13 weeks, between…
Order grouped table by id user sql
I want to order a grouped statement using as reference the number choosen by an specific user. TABLE expected result (at the end what user 1425 choosed) I want to put the last row with the number choosed by the user. i just cant figure that out Answer You can aggregate and use a conditional max for ordering, …