Rounding time - doubling output results
I hope someone can take a look at my request and easily tell me why he multiplies the results in my DURATION_MIN_AM column. It seems to be evolving date stamps / hour that I need (rounded up to the nearest 30 minutes). Is there something easily identifiable in my application that I don't see? I've been watching him for a while now and its not obvious to me at all...
WITH got_period_num
AS (SELECT
FLOOR ((stop_ts-DATE ' 2014-01-01') * 24 * 2) AS period_num,
DURATION_MIN_AM,
B.EXCEPTION_DS,
c.MU_ID,
start_ts,
stop_ts
Of
LIGHTHOUSE. IEX_AGT_ACT_DETAIL HAS
JOIN THE LIGHTHOUSE. IEX_EXCEPTION_DIM B
ON A.EXCEPTION_KEY = B.EXCEPTION_KEY
JOIN the left HEADLIGHT. IEX_AGT_ADHERENCE_ATTR C ON A.EMP_KEY = C.EMP_KEY - modified knuckles
WHERE
A.ACTIVITY_DT BETWEEN TO_DATE)
January 24, 2014 00:00:00 ',
"MM/DD/YYYY hh24:mi:ss")
AND TO_DATE)
January 24, 2014 00:00:00 ',
"MM/DD/YYYY hh24:mi:ss") AND
C.ACTIVITY_DT BETWEEN TO_DATE (24 JANUARY 2014 00:00:00 ',)
"MM/DD/YYYY hh24:mi:ss")
AND TO_DATE (24 JANUARY 2014 00:00:00 ',)
"MM/DD/YYYY hh24:mi:ss") AND
c.MU_ID IN
('220'))
SELECT
TO_CHAR)
DATE ' 2014-01-01' + (period_num / (24 * 2));
"FMMM/JJ/AAAA HH:fmMI:SS AM")
AS start_ts,
TO_CHAR)
DATE ' 2014-01-01' + ((period_num + 1) / (24 * 2));
"FMMM/JJ/AAAA HH:fmMI:SS AM")
AS stop_ts,
SUM (DURATION_MIN_AM) AS DURATION_MIN_AM,
EXCEPTION_DS,
MU_ID
Of
got_period_num
GROUP BY
period_num,
EXCEPTION_DS,
MU_ID
ORDER BY
start_ts
CREATE TABLE LIGHTHOUSE. () IEX_ACT_DETAIL
NUMBER OF EMP_KEY
NUMBER OF EXCEPTION_KEY
ACTIVITY_DT
VARCHAR2 (5)
START_TS VARCHAR2 (5).
STOP_TS VARCHAR2 (5).
NUMBER OF DURATION_MIN_AM)
CREATE TABLE LIGHTHOUSE. () IEX_EXCEPTION_DIM
EXCEPTION_DS VARCHAR2 (100),
NUMBER OF EXCEPTION_KEY)
CREATE TABLE LIGHTHOUSE. () IEX_AGT_ADHERENCE_ATTR
NUMBER OF MU_ID
NUMBER OF EMP_KEY)
INSERT IN THE LIGHTHOUSE. IEX_AGT_ACT_DETAIL (EMP_KEY, EXCEPTION_KEY, ACTIVITY_DT, START_ST, STOP_TS, DURATION_MIN_AM) VALUES (886, 000, ' 03 /' 02/2014, 3/2/2014 11:24 ', ' 03/02/2014 11:30 ', 6)
INSERT IN THE LIGHTHOUSE. IEX_AGT_ACT_DETAIL (EMP_KEY, EXCEPTION_KEY, ACTIVITY_DT, START_ST, STOP_TS, DURATION_MIN_AM) VALUES (886, 000, ' 03 /' 02/2014, 3/2/2014 11:27 ', 03/02/2014 11:31 ', 4)
INSERT IN THE LIGHTHOUSE. IEX_AGT_ACT_DETAIL (EMP_KEY, EXCEPTION_KEY, ACTIVITY_DT, START_ST, STOP_TS, DURATION_MIN_AM) VALUES (886, 000,' 03 /' 02/2014, 3/2/2014 10:02 ', 03/02/2014 10:17 ', 15)
INSERT IN THE LIGHTHOUSE. IEX_AGT_ACT_DETAIL (EMP_KEY, EXCEPTION_KEY, ACTIVITY_DT, START_ST, STOP_TS, DURATION_MIN_AM) VALUES (886, 001, ' 03 /' 02/2014, 3/2/2014 23:24 ', 03/02/2014 23:38 ', 4)
INSERT IN THE LIGHTHOUSE. IEX_AGT_ACT_DETAIL (EMP_KEY, EXCEPTION_KEY, ACTIVITY_DT, START_ST, STOP_TS, DURATION_MIN_AM) VALUES (886, 001, ' 03 /' 02/2014, 3/2/2014 21:24 ', 03/02/2014 21:38 ', 14)
INSERT IN THE LIGHTHOUSE. IEX_EXCEPTION_DIM (EXCEPTION_DS, EXCEPTION_KEY) VALUES (' 6', 000)
INSERT IN THE LIGHTHOUSE. IEX_EXCEPTION_DIM (EXCEPTION_DS, EXCEPTION_KEY) VALUES ('OPEN', 001)
INSERT IN THE LIGHTHOUSE. IEX_AGT_ADHERENCE_ATTR (MU_ID, EMP_KEY) VALUES (220, 886)
START_TS STOP_DS DURATION_MIN_AM EXCEPTION_DS MU_ID
03/02/2014 11:00 03/02/2014 11:30 10 TO THE 6 220
03/02/2014-10:00 03/02/2014-15 10:30 6 220
03/02/2014 23:00 03/02/2014 23:30 4 220 OPEN
03/02/2014 21:00 03/02/2014 21:30 14 OPEN 220
Hello
I don't know the query you posted is relevant to this problem.
It seems that this query is designed for a 1-to-many relationship between the lines in
iex_agt_detail and buckets, in other words, each line blongs to exactly 1 bucket Apaprantly, in this problem, the relationship is much to may, in other words, a single line of the table may be part of several compartments.
He gets the desired results according to the given sample data:
WITH date_range AS
(
SELECT TO_DATE (3 February 2014 00:00 '-the first time to include)
, "MM/DD/YYYY HH24.
) AS first_dt
, TO_DATE (5 February 2014 00:00 '-first time to exclude)
, "MM/DD/YYYY HH24.
) AS last_dt
OF the double
)
all_periods AS
(
SELECT first_dt + ((LEVEL - 1)
/ (24 * 2)
) AS this_start_dt
first_dt + (LEVEL
/ (24 * 2)
) AS next_start_dt
OF date_range
CONNECT BY LEVEL<= (last_dt="" -="" first_dt)="" *="" 24="" *="">=>
)
SELECT aaa.mu_id
TO_CHAR (ap.this_start_dt
, "FMMM/JJ/AAAA fmHH:MI AM.
) AS start_ts
TO_CHAR (ap.next_start_dt
, "FMMM/JJ/AAAA fmHH:MI AM.
) AS stop_ts
ed.exception_ds
, ad.duration_min_am - or SUM (...) if necessary
* LESS (ad.stop_ts (ap.next_start_dt)
-Most GREAT (ad.start_ts, ap.this_start_dt)
)
/ (ad.stop_ts
-ad.start_ts
) AS duartion_min_am
Of all_periods ap
JOIN iex_agt_detail ad WE ad.start_ts< ap.next_start_dt="">
AND ad.stop_ts > ap.this_start_dt
AND ad.activity_dt = TRUNC (ap.this_start_dt) - if necessary
JOIN iex_agt_adherence_attr aaa ON aaa.emp_key = ad.emp_key - or LEFT OUTER JOIN, if necessary
JOIN iex_exception_dim ON ed.exception_key = ad.exception_key ed
WHERE aaa.mu_id IN (220)
-GROUP BY--if necessary
ORDER BY ed.exception_ds
;
I guess just to many of your needs. For example, it is unclear if you need a GROUP BY; It looks like all the ranks of the production comes from only 1 rank of iex_agt_detail (and other tables to which it is attached). Simply GROUP IN if an output line can be 2 or more rows in the table.
This solution starts by creating a "picture" of all possible buckets: all_periods contains 1 row for each half-hour period which can be a defined result. (Since it is inner join to iex_agt_detail thereafter, only buckets that actually have some data are included in the final output).
Tags: Database
Similar Questions
-
Help with Javascript rounded times
Hello
I was wondering if someone can help me.
I have this code which doesn't seem to work. It is intended to round time only if the time by 1 minute.
For example. If the time is listed as: 21:08 then it should turn up to 22:00.
If the time is listed as: 21:00, then she must stay the same.
The problem I have is that if the time is listed as: 21:00, and then is rounded to 22:00. but should remain at 21:00
function roundUptoHour ($timestring) {}
$datetime = new DateTime ($timestring);
return $datetime-> change (' next time ' ")-> format('H').': 0 0';
}
format('H').': 0 0'; } function roundUptoHour ($timestring) { $datetime = new DateTime ($timestring); } $datetime-> modify ('-1 minutes'); return $datetime-> modify ('next hour')-> format('H').': 0 0'; } function elapsedHours ($strStart, $strEnd) { $dteStart = new DateTime (roundDowntoHour ($strStart)); } $dteEnd = new DateTime (roundUptoHour ($strEnd)); $dteDiff = $dteStart-> diff ($dteEnd); {if ($dteStart > $dteEnd) { return 24 - $dteDiff-> Format ("hour"); } else { return $dteDiff-> Format ("hour"); } } $timestart = "16:00"; $timeend = "22:00"; $hourcost = 10; $totalhours = elapsedHours ($timestart, $timeend); $timestartrounded = roundDowntoHour ($timestart); $timeendrounded = roundUptoHour ($timeend); echo "hours elapsed:". $totalhours; echo"
time start: ". $timestart." Rounded to:(".$timestartrounded.") "; " echo"
end time: ". $timeend." Rounded to:(".$timeendrounded.") "; " $timestart = "16:00"; $timeend = "22:01"; $hourcost = 10; $totalhours = elapsedHours ($timestart, $timeend); $timestartrounded = roundDowntoHour ($timestart); $timeendrounded = roundUptoHour ($timeend); echo" -
Try installing Adobe Illustrator, but it gets stuck at 42% and nothing happens. Tried 10 times and the result is the same. I leave the creative Installer and start again and try to download and then it stops. Any ideas what I could do?
If mac, delete the contents of your tmp directory and try again.
If win, delete the contents of your temp directory and try again.
-
What should be my time to latency resulting?
Please can someone tell me about what my time of latency that results should be in the Prox 10.2.4 logic?
I use an interface Apollo Twin Duo Thunderbolt, with a Macbook Pro 15' 2015 of the retina, Quad Core 2.8 ghz, 16gbRam, El Capitan 10.11.3
In preferences, it indicates the size of buffer 64
Result 10.2ms (exit 2.1ms) roundtrip latency
Is this normal? If this latency is high, how can it be reduced? I bought the most expensive interface that I could afford!
It's causing you problems? Placement of record does not affect latency.
You can hear with the help of a live microphone or guitar/bass input.
The round-trip latency is high given the size of buffer, which means that somewhere in the chain either Apple or AU-Apollo has added additional buffers.
My material RME under Snow Leopard under Logic-9 shows:
Buffer size 128 round trip latency 7.3ms out 3.7
"" 64 4.4ms roundtrip latency output 2.2
««32 2.9ms roundtrip latency output 1.5»
Normally the return buffer size is double (or slightly more) that the latency of the output, so in your case, it would be between 4.2 and 4.4ms. The pilot of Apollo or logic or the last OSX added buffers. I wouldn't be surprised if it's not Apple Core Audio, which uses the extra buffering... recent Mac operating systems are too heavy top and ineffective even if it's not that noticeable that the whole system is the additional use buffering, which is why so much RAM and open disk space is necessary. There is also the possibility that the extra buffers are part of the Thunderbolt interface?
-
I have a code below and I'm having a problem to display the results, here is the code:
Function PercentFree {
param($ds)
[Math]::Round(($ds.FreeSpaceMB / $ds.CapacityMB * 100),0)
}
$datastores = Get-Datacenter 'DataCenter' | Get-Datastore
$vDataStore = @()
$AllReport = @()
Foreach ($datastore in $datastores) {
$vDataStore = "" | Select Datastore, PercentageFree
$vDataStore.Datastore = $datastore.Name
$vDataStore.PercentageFree = PercentFree $datastore
#$AllReport += $vDataStore
if ($vDataStore.PercentageFree -lt 10) { write $vDataStore.Datastore $("$vDataStore.PercentageFree" + "Percent Free"), "`r" }
}
write "---------------------"
The last line (if statement) is send me questions, I try to have the name of the data store on 1 line, just below this line, I want the actual number for the amount in percentage and on the same line, I want the text "free percent. I am aware that write-host is more... I guess that liberal with the text, but it's gong to be included in a report script, and I thought write-host will display directly on the screen?I've been playing with the code, so I know that some things look odd, but the only problem I have is output the results. I searched online and this site an answer, but I can not entered the right search term, so sorry if the answer was posted before.TRY {0:N0}
Format P should display values between 0 and 1 percent.
This is why it displays the 8 800% value
-
Even single left mouse clicks so double clicking results on – how to stop this fake effect?
When I click on anything in Firefox, so tabs, menu items or web content on a page, my unique care left click on are interprted by Firefox like all double clicks, that has chaotic results. How can I stop this? The problem started there, having never had the problem since many years of using Firefox about 4 to 6 weeks.
This problem occurs outside of Firefox?
Try Firefox Safe mode to see if the problem goes away. Safe mode is a troubleshooting mode, which disables most of the modules.
(If you use it, switch to the default theme).
- Under Windows, you can open Firefox 4.0 + in Safe Mode holding the key SHIFT key when you open the desktop Firefox or shortcut in the start menu.
- On Mac, you can open Firefox 4.0 + in Safe Mode holding the key option key when starting Firefox.
- Under Linux, you can open Firefox 4.0 + with leaving Firefox then go to your Terminal and running Safe Mode: firefox-safe-mode (you may need to specify the installation path of Firefox for example/usr/lib/firefox)
- Or open the Help menu and click on the restart with the disabled... modules menu item while Firefox is running.
Once you get the pop-up, simply select "" boot mode safe. "
If the issue is not present in Firefox Safe Mode, your problem is probably caused by an extension, and you need to understand that one. To do this, please follow article Troubleshooting extensions, themes and problems of hardware acceleration to resolve common Firefox problems .
To exit safe mode of Firefox, simply close Firefox and wait a few seconds before you open Firefox for normal use again.
The report please come back shortly.
-
Round time to the nearest minute of you
Hello
Is there a simple way to round off a date/time to the nearest Minute?
Example: 22/03/2013 10:23:35 rounded to 22/03/2013 10:24
22/03/2013 10:23:29 rounded to 22/03/2013 10:23
I could just compare the seconds at 30 and round to the Minute or Minute + 1 but I would have to manage the change of day/month/year
Thank you
User
User79 wrote:
Hello
Is there a simple way to round off a date/time to the nearest Minute?
Example: 22/03/2013 10:23:35 rounded to 22/03/2013 10:24
22/03/2013 10:23:29 rounded to 22/03/2013 10:23
I could just compare the seconds at 30 and round to the Minute or Minute + 1 but I would have to manage the change of day/month/year
Thank you
User
Here's a way to do it.
Ben64
-
How to choose the time of search results by bing
I love how bing works. But when I want to, say, find some sales figures for February 2013, and I want to choose the results of some period of time (like "for the last month, or last week"), I can't do it. Google has this feature, and I want to know if Bing has it. and if so, how do I activate it?
Thank you
Hello
Thanks for posting your query in Microsoft Community.
I understand from the information provided, that you must support time-out feature where you should be able to search for specific time period results.
As this question is related to Bing, you can display the query in the following link.
http://www.bing.com/blogs/bingsearch/f/12244.aspx
Hope this helps, please get back to us if you have questions about Windows. We are here to help you.
-
How to show several times as output?
I have a books_issue_details table. I would like to show as output
Books table:
book_id, book_name, author_name, etc...
book_issue_details
the columns book_id, issue_id, student_id, issue_date
output:
Title 1 issued o times
Title 2 was published 4 timesOuter join to use:
with books as ( select 1 book_id,'A' book_name from dual union all select 2,'B' from dual ), book_issue_detail as ( select 2 book_id,99 student_id from dual ) select 'Title ' || t1.book_name || ' has been issued ' || count(t2.book_id) || ' times.' cnt from books t1 left join book_issue_detail t2 on t2.book_id = t1.book_id group by t1.book_id, t1.book_name / CNT -------------------------------- Title A has been issued 0 times. Title B has been issued 1 times. SQL>
SY.
-
Unwanted using utl_file.put_line output result
I don't know how the white space between the PRTA_NEW_IDN_REC. PRTA_TO_IDN and. PRTA_TRANS_ID_REC QUANTITY. Thank you for your help in advance.
UTL_FILE. Put_line (f_ID_MAINT, RPAD (NVL(PRTA_TRANS_ID_REC. COMPTE,' '), 5,' ') |)
RPAD (NVL(PRTA_NEW_IDN_REC. PRTA_TO_IDN,' '), 6,' ') |
TO_CHAR (PRTA_TRANS_ID_REC. QUANTITY, ' 099999')
);
output
A0012112010 000002
A0014112010 000001
A0023112010 000002
A0025112010 000001
A0030112010 000001
Expected result:
A0101112010000002
D1055322779000005
D1055322503000008
D1055322547000009question isn't put_line, it has to do with your mask to_char.
If you do nothing, you will get a space for positive numbers and a '-' for negative.
You must add 'fm' in front of the initial '0', and the space is removed.
You can find the masks of format in SQL language reference manual.
http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/sql_elements004.htm#SQLRF00216--------
Sybrand Bakker
Senior Oracle DBA -
How to speed up the time to query result
When executing the following query, the result comes after 22 seconds.
How I minimize this time? Please suggest.
SanjaySELECT DISTINCT PERIOD_NO, ITEM_CODE, ITEM_NAME, SUM(CASE WHEN LEVEL_TYPE IN 'SUB ZONE' THEN WD_FORECAST_QTY_BU / CNV / ML ELSE 0 END)TOT_FRCST FROM SHEET_HEAD, SHEET_DETAIL, ITEM_DETAIL WHERE WH_SYS_ID = WD_WH_SYS_ID AND ITEM_CODE = WD_ITEM_CODE(+) AND PERIOD_NO BETWEEN :PERIOD1 AND :PERIOD2 AND WH_REVISION_NO = 0 AND WH_LEVEL_CODE NOT IN (SELECT WH_LEVEL_CODE FROM SHEET_HEAD WHERE WH_REVISION_NO = 1) GROUP BY ITEM_CODE, ITEM_NAME, WH_PERIOD_NO
Hello
with speed suggest it would be always be expirement with indexing on parameters, after that first scans all what is currently happening in what concerns analyses of full table etc. which are "more expensive."
Level of the specific actions on your code, that what follows comes out too expensive; -
AND WH_LEVEL_CODE NOT IN (SELECT WH_LEVEL_CODE FROM SHEET_HEAD WHERE WH_REVISION_NO = 1)
Here, I would see if you can rewrite, perhaps with a left join / auto join to achieve the same ends, compare the timings, you might be surprised.
Kind regards
Robert.
-
Can someone help me please: I havve the following table with some data in it.
Name country Description
------------------------------------------------------------------
Big tree it's great USA
Caterpillar beautiful creatures USA
Glass houses is home of the U.S..
Japan sushi raw foods
Nice place Tokyo
Friendly people Accra Ghana
I'd leading out to be ugly out like:
U.S..
----------------------------
Big tree
It is very good
Caterpillar
Beautiful creatures
Houses
Glass Houses
Japan
-------------------------
Sushi
Raw foods
Tokyo
Nice place
Ghana
-------------------------
Acer'
Friendly people
I have the following query:
Select *.
of happy_table
order by name asc
Use cfloop to create the output or what? Help, please...
Thank you
Sevor Peter Kluprimalx2003 wrote:
>... or what? Help, please...
>The setting of the
tag group is built just for that
the purpose of the trip. CFML documentation will tell you all this.With respect to Adam, but since I'm passing time while Adobe Premiere
Pro CS3 installed, I'll give you some tips while I wait.You want to order your record set by the first country.
SELECT Name, Description, country
OF happy_table
ORDER BY country, name.Then you have nested to outings.
#happyQry.country #.
------------------------------------------
#happyrQry.Name #.
#happyQry.Description #.
Well, it looks like my software package is installed, you will have
to read the fine manual for more details.HTH
Ian -
How the heck can I get rid of the drop downs. I have try several times with no results
GET RID OF DROP DOWNS (STORY) WHEN I TOUCH TO AN ADDRESS
Do you mean on the address bar of Firefox, where appears the URL, or as a web page that needs to enter your address?
For the Firefox address bar, the categories of data displayed in the menu drop-down are defined in the Options page, Privacy panel. See this article for more information:
Awesome Bar - find your Firefox bookmarks, history and tabs in the address bar - go to the section "How can I control what shows the address bar results, me?
For forms in web pages, if you want to disable auto form fill completely, you can do that also on the Options page, sign confidentiality. See this article for more information:
Check if Firefox automatically fills in forms
Who help me?
-
Portege R600 / A600 and double output screen
Hello
Could you tell me if it is possible to output to two screens on the R600 or A600 with any of the Toshiba Docking solutions?
I was told that it is possible, however I was told today by the sales of Tosh is not possible to do. I want to end my home pc and the desktop pc and just wander between the two with a laptop. However, I use an extended desktop on both screens and would need this work.
Any advice on that?
Thank you
Paul
Hello
As far as I know you can t use two external displays. It is only possible to use the internal LCD screen with * a * external LCD display. That s what you can do.
But I put t understand why you want to use two external displays the internal display is good, you can extend the Windows desktop on an external monitor.
-
Graphics card double output for the motorway A58
Hi guys,.
Work just gave me a Lenovo A58 SFF and while I don't have the serial number, I don't know what follows-
Lenovo ThinkCentre A58
Small form factor
Intel CORE 2 QUAD Q8400
4 GB OF RAM
Hard drive 320 GBThe machine is used only for work (spreadsheet, processing and internet) and I would like to run two monitors (both with VGA, PCI and HDMI inputs), but Lenovo A58 LTS offers only one VGA output.
I did a quick search for graphics in this forum, but suggestions seem to be a little out of date as the machine is a bit long in the tooth now.
As I work for a small business, we do not have a 'IT Department', so it is left up to me to sort.
If you could please provide me with some options, it would be much appreciated.
Thank you
Chris.
(1) the onboard graphics on the A58 can support 2 monitors. The card is in fact the second connector for the integrated graphics card.
(2) limitation is that to do with graphics performance, you can not play on it. But Office apps will work fine. normal movies will work as well.
(3) it's a true second monitor, you can expand the view to make both monitors independently managed.
Maybe you are looking for
-
I downloaded and installed firefox 6.0 and now everytime I open firefox 6.0, I get two windows, my normal home page and the other is the welcome of firefox window that I don't want to see.
-
I use Windows XP Prof SP3. I was going over my "program files folders" in WIndows Explorer and noticed a "ESTsoft' folder. I checked Add/Remove Programs, but there is no software on the list program. What is ESTsoft, how does settle, and the removabl
-
pressing the key "w" lance programs that I don't want to open.
Whenever I hit the "w" key on my keyboard, it opens the programs that I don't want to not open. ITunes, internet explore etc. open up and stop what ever I am working. It is a real headache when I work on word documents. How can I stop this?
-
I want to make my laptop, a computer laptop mutiboot
I want to make my computer vista laptop on a computer mutiboot. I want to have my computer vista and 98 more, not only vista. I have the software but I do not know how, can someone help me?
-
Signature keys: author.p12 file is not created
I'm running the installation program to sign my BB10 app, but the author.p12 file is not created barsigner. CSK and barsigner.db the file is created, but author.p12 file is not created. While creating the files, the control interface gives the result