I have to create a service availability using info from this 2 query. First Query. example result second query example result The formula as below ((Reporting Period – Unplanned Outage)/Reporting Period)*100 Answer Consider using conditional aggregation: The availability computation could probably be simplified:
Tag: count
Grouping the result set based on conditions
I am calculating Age of a user based on his date of birth. This gives me the UserId and his age. Now I want to group this result. How many users are in 30’s, How many users in 40’s and how many users in their 50’s.. need the count of users with their age groups If the user is >
SQL – Count rows based on matching columns and value range
Please see below query using T-SQL with SSMS. There are three tables: B, G and L. B has a column Bname G has 2 columns Gname, Gross L has 2 columns Bname, Gname Gross column is an INT ranging …
Division of 2 values in mysql
Hello I’m a newbie in SQL. I have a table of workers and I want to calculate the avg num of female workers. I want to divide 2 tables that I create, but when I do the division the value of the new …
Postres SQL select with GROUP BY and COUNT
i have this SQL select SELECT t.debtor_account, COUNT(t.debtor_account) FROM transaction t GROUP BY t.debtor_account HAVING COUNT(t.debtor_account) > 2; which work, but i need select all from …
Using Over() with aggregate functions while calculating percentage
I am writing a query to print Total Students in each department in a college, I also want to print the percentage of those students in each department out of Total students in the college. Having issues with calculating percentage, the above query throwing an error dbo.Student.Id is invalid in the select list because it is not contained in either
Can you use ORDER BY (column) LIMIT with a secondary column?
I want to find out the Top 10 rented movies in the sakila db. It must be sorted DESC after total_rentals and secondary after film title. My solution looks like this and works so far without the film …
Select only the records with same values
I am working on a SQL statement that will become a part of a view. What I need is to extract only the records that have the same unique key twice. The query looks like below right now. The result I get from the query above is: I need to modify the SQL statement so that the end result is
What kind of join should I implement in order to receive the output I am trying to get?
NOTE: Just a practice problem.. NOT looking for free homework answers. The practice problem I have asks to report the number of flights by plane’s year in ascending order of plane’s year. This requires the joining of two tables, the flights table and planes table. I believe the SQL should be relatively simple, and I think the main issue with
How can I create a column which computes only the change of other column on redshift?
I have this dataset: The dataset has the product the company sells and the customers who saw the product. A customer can see more than one product, but the combination product + customer doesn’t have any repetition. I want to get how many people bought the product before the customer sees it. This would be the perfect output: As you