I’m working in MS Access trying to iron out an SQL statement that works. On a form I have a combobox that displays a list of employees. I have a separate dialog form that allows the user to select …
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…
SQL Server indexing includes questions
I’ve been trouble shooting some bad SQL calls in my works applications. I’ve been reading up on indexes, tweaking and benchmarking things. Here’s some of the rules I’ve gathered (let me know if this …
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:
In SQL I want to display the names of all those cities which end with an vowel
I wrote the following query What is wrong with this? Answer If you want it to work with lower/upper letters, you could use UPPER(CITY), otherwise it’s all good.
RETURNING rows using unnest()?
I’m trying to return a set of rows after doing UPDATE. Something like this. but postgres complains, rightly so: set-valued function called in context that cannot accept a set How am I supposed to go about implementing this? That is, RETURNING a set of rows from SELECTed array after UPDATE? I’m awa…
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…
SQL Server – group by with row number – Gaps and Islands
I have a table with data like this I need to create a view on top of this table to have data formatted in the below format for the Flag, basically the duration for which the Flag was Y or N. (EndDateSID – 0 is currently active, so today’s date) Most customers only have a change in their Flag once,