My table 'Stops' looks like this:
Id TimeStart TimeFinished StopType
1 06:00 07:00 1
2 08:00 09:00 2
3 10:00 11:00 3
and so on...
The entries are different types of stops, planned, unplanned etc, defined by 'StopType'. Everything not within a timerange is 'production time', like between 07:00 and 08:00.
I want to make a timeline that includes the production time.
Result:
TimeStart TimeFinished StopType
06:00 07:00 1
07:00 08:00 5
08:00 09:00 2
09:00 10:00 5
10:00 11:00 3
where (StopType = 5) = production time
Any help is much appreciated!
Related
How can I use a 0 as a "placeholder" here?
=QUERY(Data!A1:G578, "select G, sum(C) where D='Income' group by G label sum(C) 'Total Income'")
So that
Month
Total Income
August 2021
$784.59
October 2021
$200.00
November 2021
$312.74
becomes
Month
Total Income
August 2021
$784.59
September 2021
$0.00
October 2021
$200.00
November 2021
$312.74
The quickest hacky fix would be just to have an entry of 0$ for September in the data somewhere, but I am wondering if there is a more ""professional"" way to do it
I am having this issue and any help in this regard will greatly be appreciated.
I have Oracle db and working with following business case:
An employee can work in a different job grades in his/her regular time hours or in overtime
Need to calculate employee’s hours w.r.t. different job grades and wage codes, because I have hours and job grades in different tables and the table which has job grades doesn’t have hours, instead time in and time out so after querying the db I get the following result.
Emp_ID
Wage Code
Job grade
Hours
Date
1
01
8
2021/06/07
1
02
P
2
2021/06/07
1
08
8
2021/06/08
1
01
6
2021/06/09
1
01
E
8
2021/06/09
1
01
8
2021/06/10
1
01
8
2021/06/11
1
02
9
2021/06/11
Now I get wrong hours when the employee works in different job grade(s).
To overcome this, I need to identify on which date employee worked in a different job grade do I can put case statement.
I used this logic.
Pick the date on which employee worked in different job grade and on that date do calculation of hours from table A
Other wise do calculation of hours from table B.
The problem is I can’t simply use variables because there could be multiple dates.
How can I achieve this? Can I use any other logic?
Thanks,
Here are my tables
TABLE A
Emp_ID
Wage_code
time_in
time_out
Job_grade
Date
01
8:00
16:00
2021-06-7
01
16:00
18:00
P
2021-06-7
01
8:00
16:00
2021-06-08
01
8:00
14:00
2021-06-09
01
14:00
16:00
E
2021-06-09
01
8:00
16:00
2021-06-10
01
8:00
16:00
2021-06-11
01
16:00
17:00
2021-06-11
This table doesn't store wage_codes. empty job_grade means employee has worked in the same job grade
TABLE B
Emp_ID
Wage_code
Hours
Date
01
1
8
2021-06-7
01
2
2
2021-06-7
01
8
8
2021-06-08
01
1
8
2021-06-09
01
1
8
2021-06-10
01
1
8
2021-06-11
01
2
2
2021-06-11
This table stores wage_codes but no job grade change, just a regular one and hours for each wage_code (1=regular,2=overtime,8=vacation etc..)
my query
select
A.emp_id,
A.job_grade,
B.Wage_code,
B.Date,
case
when A.job_grade ='' then B.Hours
else
to_char(A.time_in - A.time_out) *(24),'fm99.90')
end "Hours"
from A
left join B on A.emp_id=B.emp_id and A.Date=B.Date
With this query I get wrong hours when employee has worked in a different job grade. Because the condition in case statement checks if job grade is empty then calculate hours from Table B. Now e.g. on 06/07, employee has worked in a normal grade as well as in a different job grade.
How can I identify the date on which employee has worked in a different job grade so I can combine it with the job_grade condition in case statement and calculate hours accurately.
Many thanks for your support!!
oracle version: 11.2.0.1.0
When I try to generate an AWR Report in Oracle use sysdba,
exec dbms_workload_repository.create_snapshot();
I keep getting this error:
ORA-00600: [kewrose_1], [600], [ORA-00600: [13013], [5001], [6213], [8465936], [5], [8447794], [17], [], [], [], [], []
], [], [], [], [], [], [], [], [], []
I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this
conn / as sysdba
SQL> #$ORACLE_HOME/rdbms/admin/awrrpt.sql
SQL> #$ORACLE_HOME/rdbms/admin/awrrpt.sql
Current Instance
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
3400239050 TEP 1 TEP
Specify the Report Type
AWR reports can be generated in the following formats. Please enter the
name of the format at the prompt. Default value is 'html'.
'html' HTML format (default)
'text' Text format
'active-html' Includes Performance Hub active report
Enter value for report_type: dec
Type Specified: dec
Instances in this Workload Repository schema
DB Id Inst Num DB Name Instance Host
------------ -------- ------------ ------------ ------------
* 3400239050 1 TEPCBC TEP oldman
Using 3400239050 for database Id
Using 1 for instance number
Specify the number of days of snapshots to choose from
Entering the number of days (n) will result in the most recent
(n) days of snapshots being listed. Pressing without
specifying a number lists all completed snapshots.
Entering the number of days (n) will result in the most recent
(n) days of snapshots being listed. Pressing without
specifying a number lists all completed snapshots.
Enter value for num_days: 1
Listing the last day's Completed Snapshots
Snap
Instance DB Name Snap Id Snap Started Level
TEP TEP 38542 20 Dec 2022 00:30 1
38543 20 Dec 2022 01:30 1
38544 20 Dec 2022 02:30 1
38545 20 Dec 2022 03:30 1
38546 20 Dec 2022 04:30 1
38547 20 Dec 2022 05:30 1
38548 20 Dec 2022 06:30 1
38549 20 Dec 2022 07:30 1
38550 20 Dec 2022 08:30 1
38551 20 Dec 2022 09:30 1
38552 20 Dec 2022 10:30 1
38553 20 Dec 2022 11:30 1
38554 20 Dec 2022 12:30 1
38555 20 Dec 2022 13:30 1
38556 20 Dec 2022 14:30 1
38557 20 Dec 2022 15:30 1
38558 20 Dec 2022 16:30 1
38559 20 Dec 2022 17:30 1
38560 20 Dec 2022 18:30 1
38561 20 Dec 2022 19:30 1
38562 20 Dec 2022 20:30 1
Specify the Begin and End Snapshot Ids
Enter value for begin_snap: 38542
Begin Snapshot Id specified: 38542
Enter value for end_snap: 38544
End Snapshot Id specified: 38544
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_1_38542_38544.html. To use this name,
press <return> to continue, otherwise enter an alternative.
Enter value for report_name: test2
Using the report name test2
<html lang="en"><head><title>AWR Report for DB: TEP, Inst: TEP, Snaps: 38542-38544</title>
<style type="text/css">
body.awr {font:bold 10pt Arial,Helvetica,Geneva,sans-serif;color:black; background:White;}
I have rollup output of month-wise average sales of products in a quarter as shown below:
Rollup output:
Product Month Sales
------------------------------
Product1 MAY 101.27
Product2 MAY 5.47
Product1 JUN 1481.19
Product2 JUN 84.95
ALL QTR 836.44
I need final output in the following format:
Product1 Product2 AverageSales
May 101.27 1481.19 (null)
Jun 5.47 84.95 (null)
Jul 0 0 (null)
ALL (null) (null) 836.44
I tried to apply pivot on month but since month name is a dynamic value based on the quarter selected, I tried to pivot on the product:
select * from (rollup output)
PIVOT MIN(Sales) FOR Product IN ('Product1' AS Product1_sales, 'Product2' AS Product2_sales, 'ALL' AS Average Sales');
I received the following output:
MONTH Product1_sales Product2_sales Average Sales
MAY 5.47 (null) (null)
MAY (null) 101.27 (null)
JUN 84.95 (null) (null)
JUN (null) 1481.19 (null)
Qtr (null) (null) 836.44
However, I need data in the final format mentioned above. How can I achieve this?
Also, if data for a given month of the quarter is not available, I want to display its value as 0 (also shown in the final format above). How can I achieve that, considering that month name is dynamic?
Edit: I can pivot using product as well since I do not want xml output that comes out of dynamic pivot.
I'm not sure why it needs to be dynamic since the number of months is unlikely to change. Why not just:
select product
, nvl(jan,0) as jan
, nvl(feb,0) as feb
, nvl(mar,0) as mar
, nvl(apr,0) as apr
, nvl(may,0) as may
, nvl(jun,0) as jun
, nvl(jul,0) as jul
, nvl(aug,0) as aug
, nvl(sep,0) as sep
, nvl(oct,0) as oct
, nvl(nov,0) as nov
, nvl(dec,0) as dec
from rollup_output
pivot (min(sales) for (month) in
( 'JAN' as jan, 'FEB' as feb, 'MAR' as mar, 'APR' as apr, 'MAY' as may, 'JUN' as jun
, 'JUL' as jul, 'AUG' as aug, 'SEP' as sep, 'OCT' as oct, 'NOV' as nov, 'DEC' as dec)
);
SQL Fiddle
I have a graph that compares transactions from the last 7 days (including the current day), to the 7 days before that.
However, I've noticed that sometimes during the day, the order of the days is incorrect.
When I open the report again it is the correct, without me doing anything to fix it.
The above graph was created on Sunday morning, and the Saturday and Friday values are switched around. Since it's Sunday morning, the graph should start on Monday, and end on Sunday.
Later on, it displayed as it should.
The data is as follows (unfortunately I could only pull data as it was when the graph was shown correctly.) There are 2 products that are grouped together in the graph.
Brand Date DepositAmount DayOfWeek WeekSeries
B 10/02/2014 1630 Monday Previous Week
A 11/02/2014 13717 Tuesday Previous Week
B 12/02/2014 2460 Wednesday Previous Week
A 13/02/2014 4941 Thursday Previous Week
A 18/02/2014 9194 Tuesday Current Week
B 19/02/2014 1947 Wednesday Current Week
A 20/02/2014 4185 Thursday Current Week
B 21/02/2014 273 Friday Current Week
A 22/02/2014 2521 Saturday Current Week
B 22/02/2014 1118 Saturday Current Week
A 23/02/2014 1438 Sunday Current Week
B 23/02/2014 105 Sunday Current Week
A 14/02/2014 4958 Friday Previous Week
B 14/02/2014 1023 Friday Previous Week
A 15/02/2014 2465 Saturday Previous Week
B 15/02/2014 1208 Saturday Previous Week
A 16/02/2014 3495 Sunday Previous Week
B 16/02/2014 680 Sunday Previous Week
A 17/02/2014 2726 Monday Current Week
B 17/02/2014 1177 Monday Current Week
A 10/02/2014 4938 Monday Previous Week
B 11/02/2014 1543 Tuesday Previous Week
A 12/02/2014 7891 Wednesday Previous Week
B 13/02/2014 5490 Thursday Previous Week
B 18/02/2014 4726 Tuesday Current Week
A 19/02/2014 9009 Wednesday Current Week
B 20/02/2014 459 Thursday Current Week
A 21/02/2014 6012 Friday Current Week
In SSRS, the graph is defined as follows:
Category Groups: DayOfWeek (sorted by Date (A to z))
Series Groups: WeekSeries (sorted by WeekSeries (A to Z)).
Any ideas what may be causing this issue?
I think the issue is in your Category Group sort - you are Grouping by DayOfWeek but then sorting by Date which has multiple values. The first row for Friday could get the Current Week Date or the Previous Week Date at random.
To fix this, for the Category Group sort, I would derive a "Relative DayOfWeek" value, something like:
= Abs ( DateDiff ( DateInterval.Day , Today() , Iif ( Fields!WeekSeries.Value = "Current Week" , Fields!Date.Value, DateAdd ( DateInterval.Day , 7 , Fields!Date.Value ) ) )