Skip to content

Capacity Management database

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…

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 …

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?…

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, …