Skip to content

Average value for top n records?

i have this SQL Schema: http://sqlfiddle.com/#!9/eb34d In particular these are the relevant columns for this question: ut_id,ob_punti I need to get the average of the TOP n (where n is 4) values of …

Telecommunication app database design [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year. Improve this question I would just like to ask or get a few expert advices/directions on buil…

Select minute from CURTIME() in a sql query

I have a column with CURTIME() value. I want a query that selects the minute from the column with CURTIME() and copy the minute to another column. Answer You could use the minute function. If you’re just querying it: To save this value to another column:

Count rows after joining three tables in PostgreSQL

Suppose I have three tables in PostgreSQL: Suppose I am using the using the following query: I get 50 as count. Whereas with: I get only 25 as count. What is my mistake in the second query? What can I do to get the same count? My requirement is that there is a single user table, referenced by multiple tables.

How to calculate power consumption from power records?

I have table which contains power values (kW) for devices. Values are read from each device once a minute and inserted into table with timestamp. What I need to do is calculate power consumption (kWh) for given time span and return 10 most power consuming devices. Right now I query results for given time span…