SELECT (SELECT SUM(kwh) FROM energy_logger WHERE TIME >= ’05:30:00′ AND TIME = ’18:30:00′ AND …
Tag: sql
Unable to run simple presto shell query
I am trying to run simplest query. However it is not working. -bash-4.2$ prestosql –execute “select 1;” Exception in thread “main” io.airlift.airline.ParseArgumentsUnexpectedException: Found …
How to add a column of total number of rows in BigQuery
I have a table in BigQuery where I save a DATESTAMP and temperature sensor value. I usually filter the query by dates. My goal is to add a column in this query where it puts the total number of rows. For example, if I run this query I have this result: And when I run this query I have this
Too many open connections on sending Email
I’m trying to send email to every users from DB. I use a loop to get the message text per user as I loop need to call the send_email. But I got an error saying: ORA-30678: too many open connections …
How to select certain number of rows from large query result set in Teradata sql
I am new to Teradata sql and I have a query that selects over one million rows. I want to write teradata sql to select the first 500,000 rows, then the next 500,000 rows and then the last 100,000 + rows in my data set. For the first set I know I can use SELECT * FROM QRY1 ORDER BY
How to use VBA variable in SQL string? Enter Parameter Value error
I get a popup box asking for the parameter value for the value of CXIid Enter Parameter Value for CXI00012. I tried ‘ ” & CXIid & ” ‘ but then I get a result of 0 rows being updated. However when I put a value in the where clause or into the Enter Parameter Value prompt I get t…
What is the best way in SQL to combine sequential events based on matching end time to start time?
That database I work in records events based on a part ID and the times in which it is active. The issue I came across is these events are truncated to fit within a single day. If the active time for a part carries over to the next day, the event will be split by the number of days it
How to flatten Rows into Column (Field) Values
I have data that has Job_ids split across multiple rows (i’ve had to do this because previously i’ve had to split out team members from each job_id, then identify their teams The format my data is currently in is as follows, (not shown) but each job_id has an employee who has a team assigment, and…
Hive – Merge rows with search term substrings
I got a search results log table with search terms in one of the columns. Since the search results are produced as the user types in the search terms, there are multiple rows for each search term with the partial string. For example, as the user types world the resulting rows in the table will be: Expected re…
What is the best solution for adding INDEX to speed up the query?
Now I have a Query that runs 50 minutes on Mysql database and I can’t accept that… I want this process can running under 15 minutes…. The “sourcetableid” and “mstid” are unique. So what is the best way to add INDEX or optimize on this? Thank you Answer I would write t…