Function to calculate the days of work
Hi all
I accidentally develop an application in which I had to follow the thread below and it works perfectly for the weekend (Saturday and Sunday)
PL/SQL function to calculate the non-working days
Now, my specific question is: how to implement the same function , but weekends (Fri & sat).
I tried to recognize the logic behind the calendar to change the days of the weekend, but I suspect.
I need your recommendation around this function specifically.
!-[CodeBlockStart:3cad70b5 - 81 a 0-4f6b-909 a-cacb29e25953]--> BOX WHEN IN l_case (-"Mon6", "Tue5", "Wed4", "Thu3", "Fri2" - exclude Saturday & Sunday, workday begins from Monday 'Sun6', 'Mon5', 'Tue4', 'Wed3', 'Thu2' - remove begins day 2 business days (Fri & sat) on Sunday and maintaining the order of the sequences,-"Sat1", "Sun1", "Sun2', 'Sun3', 'Sun4' - Include weekend can be for the rest of the week) , "Sat1", "Sat2", 'Fri1', "Sat3", "Sat4" - includes my week ends replace (with FRI Sat) & (Sun to SAT) & law enforcement-sequence, "Sun5', 'Sun6',"Sat5","Sat6"- replace (Sun with Sam). ) 1 THEN WHEN IN l_case (-'Tue6', 'Wed5', 'Wed6', 'Thu4', "Thu5" - Old (Saturday and Sunday) end over the next week - I guess - sequence of days - since the week days sequence Changed (number 1 or 1 step backward) when numbers also changed accordingly "Tue5", "Wed4", "Wed5", "Thu3", "Thu4" - ok-, 'Thu6', 'Fri3', "Fri4", "Fri5", "Fri6", "Thu5", "Sun1", "Sun2", 'Sun3', 'Sun4' - contiue to Thu sequence number & then replace my current (Friday) holiday with start of work dat (Sun) "Fri1") (, 'Fri2', 'Fri3', 'Fri4', "Fri5") THEN 2 0 OTHERWISE END;
Thanks in advance.
Amatu Allah
with
calendar as
(select dat_val,
cases where to_char(dat_val,'mm-dd') in (12-25', 12-26', ' 01-01')-in fact select the host table to_char(holiday_date,'mm-dd')
then "vacation."
When to_char (dat_val, 'Dy') in ('Friday', 'Saturday')
then 'weekend '.
else 'work '.
end dat_type
sum (case when to_char(dat_val,'mm-dd') in (12-25', 12-26', ' 01-01'))
then 0
When to_char (dat_val, 'Dy') in ('Friday', 'Saturday')
then 0
1 other
end
) on working_count (dat_val control)
from (select date "' 2015-12-01 + level - 1 dat_val)
of the double
connect by level<=>=>
)
)
Select dat_val,
dat_type,
working_count
calendar
where dat_val between to_date(:lo_date,'yyyymmdd') and to_date(:hi_date,'yyyymmdd')
and dat_type! = work «»
DAT_VAL | DAT_TYPE | WORKING_COUNT |
---|---|---|
11/12/2015 | end of week | 8 |
12/12/2015 | end of week | 8 |
18/12/2015 | end of week | 13 |
19/12/2015 | end of week | 13 |
25/12/2015 | holiday | 18 |
26/12/2015 | holiday | 18 |
01/01/2016 | holiday | 23 |
02/01/2016 | end of week | 23 |
08/01/2016 | end of week | 28 |
09/01/2016 | end of week | 28 |
Select to_date(:lo_date,'yyyymmdd') lo_date,
to_date(:hi_date,'yyyymmdd') hi_date,
dat_val,
dat_type,
working_count,
Lead (working_count) more (order of dat_val) - working_count + 1 working_days,
to_date(:hi_date,'yyyymmdd') - to_date(:lo_date,'yyyymmdd') - lead (working_count) (order dat_val) + working_count non_working_days
calendar
where dat_val in (to_date (:hi_date,'yyyymmdd'),to_date(:lo_date,'yyyymmdd'))
LO_DATE | HI_DATE | DAT_VAL | DAT_TYPE | WORKING_COUNT | WORKING_DAYS | NON_WORKING_DAYS |
---|---|---|---|---|---|---|
10/12/2015 | 10/01/2016 | 10/12/2015 | work | 8 | 22 | 10 |
10/12/2015 | 10/01/2016 | 10/01/2016 | work | 29 | - | - |
Concerning
Etbin
Tags: Database
Similar Questions
-
Calculation of the days of working in a function
I have a function that will count the total number of days between two weeks. That is, May 19, 2010 to June 18, 2010 is 30 total days in my cycle. We do not work on weekend so that 30 days is not correct. The formula below is how I calculate the days between cycles. Is it possible to not counting the weekend in my cycle? Please see the formula below:
TIMESTAMPDIFF (SQL_TSI_DAY, "Free Dim". "Release cycle Start Date ', 'Release Sun'." Output cycle end Date")You should subtract the start end date date, divide by 7 and multiply by 5.
Try with it.
Concerning
-
Dear friend
I want to calculate the days of salary. We pay the salaries of the 21st of the month last to the 20th of the current month.
I want to create a view where it will show of the the Scriptures based on this month wise condition
Select empno, name, daytype, count (empno) days, MAX (TO_CHAR (ADATE, 'MONTH')) in dailyattendence
When al > =('20-OCT-2010') AND ADATE < =('20-NOV-2010')
Group by empno, daytype
order by empno
for ex
562 SEUN BÉLANGER AFTERNOON OCTOBER 1
562 SEUN BÉLANGER MORNING OCTOBER 2
562 SEUN BÉLANGER NIGHT OCTOBER 2
562 SEUN OFF BÉLANGER 1 OCTOBER
562 SEUN BÉLANGER AFTERNOON NOVEMBER 1
562 SEUN BÉLANGER MORNING 2 NOVEMBER
562 SEUN BÉLANGER NIGHT NOVEMBER 2
562 SEUN OFF BÉLANGER 1 NOVEMBER
Suggest me how to set the dates so that I can get the report as shown above,
SandyIt doesn't really have anything to do with the forms, but here's a solution.
To get the 21st of the month before you use:select to_date('21'||to_char(add_months(sysdate,-1),'mmyyyy'),'ddmmyyyy') from dual; TO_DATE(' --------- 21-OCT-10
The same for the 20th of this month. So you get:
where adate between to_date('21'||to_char(add_months(sysdate,-1),'mmyyyy'),'ddmmyyyy') and to_date('20'||to_char(sysdate,'mmyyyy'),'ddmmyyyy')
An addition: If your date includes a time, you must use the use trunc (date).
Published by: InoL on November 11, 2010 12:10
-
PL/SQL function to calculate the non-working days
Hello
I have the following pl/sql function which generates a number of days between two selected dates (i.e. excluding weekends). However, I also need to exclude specific holidays - day of Christmas etc. These holiday dates are stored in a table in our database (11 GR 2) called "HOLIDAY".
How can I integrate the holidays which is held in the table of holidays in the following query to exclude these dates as well? I know how to write a separate funtion pl/sql for a number of days between two dates using SELECT... BUT I can't work out how to bring together them in a single query.
Could someone show me how with the pl/sql / dates below please?
Example of HOLIDAY table below.
Thank you!
TP
create or replace function WORKING_DAYS (pi_start_date in date, pi_end_date in date) return integer is v_start_date date :=pi_start_date; v_end_date date:=pi_end_date; v_count integer:=0; begin while v_start_date <= v_end_date loop if to_char(v_start_date,'D') not in ('6','7') then v_count := v_count+1; end if; v_start_date:=v_start_date+1; end loop; return v_count; end;
(select '10-Apr-2013' as NWD from dual union all select '06-May-2013' from dual union all select '27-May-2013' from dual union all select '26-Aug-2013' from dual union all select '26-Dec-2013' from dual union all select '25-Dec-2013' from dual union all select '01-Jan-2014' from dual union all select '18-Apr-2014' from dual union all select '21-Apr-2014' from dual union all select '05-May-2014' from dual union all select '26-May-2014' from dual union all select '25-Aug-2014' from dual union all select '25-Dec-2014' from dual union all select '26-Dec-2014' from dual) HOLIDAYS
Hello
the link is on MOSC, not OTN... Here's a copy:
This function calculates the number of days between two dates, ignoring weekends and holidays (if requested and if the holidays are stored in a table)
I give an example of table 'public_holiday' with sample data, but users must ensure that their table contains the relevant data (all holidays within the maximum range of use of the service)
CREATE TABLE public_holiday (calendar_day, DATE, text VARCHAR2 (30));
FUNCTION to CREATE or REPLACE nb_days (p_date_from IN DATE
p_date_to DATE by DEFAULT TRUNC (sysdate)
, p_public_holidays in CHAR DEFAULT 'Y '.
) RETURN NUMBER
DEFINE AUTHID
AS
/*********************************************************************/
/ * Author: Bruno Vroman * /.
/ * Created: 23-AUG-2012 * /.
/ * Last updated: 23-AUG-2012 * /.
/ * Object: to calculate the number of days between 2 dates, to the exclusion of * /.
/ * Saturday and Sunday, but also "holidays" If the * /.
/ * argument 'p_public_holidays' = 'Y ' * /.
/ * Support: p_date_from<= p_date_to ="">=>
/ * component ' hour min dry "ignored (just counting days) * /.
/* First step: */
/ * the calendar days between 2 days * /.
/ Remove 2 days for each "week" and 0 or 1 extra day * /.
/ * function to a condition "complex" mix day of first week * /.
/ * and the number of days when full remaining weeks are removed * /.
/ * (set up once for all, for example if there is 3 days and the * /)
(/ * first day is a Thursday, there is 1 "Sat/Sun" to subtract) * /.
/ * Second step: If 'p_public_holidays' = 'Y': other * /.
/ * days, do not count holidays. */
/ Holiday everyday are defined in a table "public_holiday" * /.
/ * Note: there may be holidays defined on Saturday/Sunday. */
/*********************************************************************/
l_result NUMBER;
l_from DATE;
l_to DATE;
l_case tank (4);
BEGIN
l_from: = TRUNC (p_date_from);
l_to: = TRUNC (p_date_to);
l_case: = TO_CHAR (l_from, 'Dy', 'NLS_DATE_LANGUAGE = English').
To_char (MOD (l_to - l_from + 1, 7));
l_result: = l_to - l_from + 1
-TRUNC ((l_to-l_from + 1) / 7) * 2
-CASE
WHEN l_case IN ('Mon6', 'Tue5', 'Wed4', 'Thu3', 'Fri2'
, "Sat1", "Sun1", "Sun2', 'Sun3", "Sun4".
, "Sun5', 'Sun6.
)
THEN 1
WHEN l_case IN ('Tue6', 'Wed5', 'Wed6', 'Thu4', "Thu5"
, 'Thu6', 'Fri3', 'Fri4', 'Fri5', 'Fri6 '.
, "Sat2", "Sat3', 'Sat4', 'Sat5", "Sat6.
)
THEN 2
0 OTHERWISE
END
;
IF SUPERIOR (p_public_holidays) = "Y".
THEN
SELECT l_result - COUNT (*)
IN l_result
OF public_holiday p
WHERE p.calendar_day > = l_from
AND p.calendar_day<=>=>
AND SUBSTR (TO_CHAR (p.calendar_day
, "Dy".
'NLS_DATE_LANGUAGE = English'
)
, 1, 1 ) != 'S'
;
END IF;
RETURN l_result;
EXCEPTION
WHILE OTHERS
THEN
DBMS_OUTPUT. Put_line (' CTF nb_days (' |))
To_char (p_date_from, "MON-DD-YYYY"). ', ' ||
To_char (p_date_to, "MON-DD-YYYY"). ', ' ||
p_public_holidays | ' ) : ' || SQLERRM
);
LIFT;
END nb_days;
/
REM
REM example:
REM A) fill out the 'public_holidays '.
REM
TRUNCATE TABLE public_holiday;
INSERT INTO public_holiday VALUES (DATE ' 2012-01-01', ' new year (a Sunday)');
INSERT INTO public_holiday VALUES (DATE '' 2012-01-03, "for example");
REM (insert other days...)
COMMIT;
Call the function for some pairs of dates of REM B)
REM nb1: remove only Sat/Sun
REM nb2: also remove holidays
REM
ALTER SESSION SET nls_date_format ='Dy DD-MON-YY';
WITH some_dates AS
(SELECT DATE ' 2011-12-29'd dual FROM
UNION ALL SELECT DATE ' 2012-01-08' FROM dual
UNION ALL SELECT DATE ' 2012-01-10' FROM dual
)
SELECT d1.d 'FROM '.
, d2.d ' to THE '.
, nb_days (d1.d, d2.d, ' don't) nb1
, nb_days (d1.d, d2.d, 'Y') nb2
OF some_dates d1
some_dates d2
WHERE d1.d<=>=>
ORDER BY nb1, nb2, d1.d
;
GO TO NB1 NB2
------------- ------------- ---- ----
Monday, January 8, 12 Monday, January 8, 12 0 0
Friday, December 29, 11 Friday, December 29, 11 1 1
Wednesday, January 10, 12 Wednesday, January 10, 12 1 1
Monday, January 8, 12 Wednesday, January 10, 12 2 2
Friday, December 29, 11 Monday, January 8, 12 7 6
Friday, December 29, 11 Wednesday, January 10, 12 9 8
Hope that this could be useful, but note that this code has not been completely tested, so check and test before you trust it (in the case of any questions, please post a comment)
Bruno Vroman.
Best regards
Bruno
-
Function to calculate the Minutes of business between two Dates
Hello
I use the version of database Oracle 11.2.1. I would like to calculate the number of minutes of work between the two dates where working hours are Monday - Thursday from 08:45 to 17:00 and Friday from 08:45 to 16:30
I found the following function useful in a similar position but wanted help picking up the days and the hours above into account
CREATE OR REPLACE
FUNCTION get_bus_minutes_between(
p_start_date DATE,
p_end_date DATE
)
RETURN NUMBER
IS
v_return NUMBER;
BEGIN
with t as (
select case level
when 1 then greatest(p_start_date,trunc(p_start_date) + 9 / 24)
else trunc(p_start_date) + level - 15 / 24
end start_dt,
case connect_by_isleaf
when 1 then least(p_end_date,trunc(p_end_date) + 18 / 24)
else trunc(p_start_date) + level - 8 / 24
end end_dt
from dual
connect by level <= trunc(p_end_date) - trunc(p_start_date) + 1
)
select sum(greatest(end_dt - start_dt,0)) * 24 * 60 work_minutes
into v_return
from t
where trunc(start_dt) - trunc(start_dt,'iw') < 5; -- exclude weekends
RETURN v_return;
END;
/Can anyone help?
Hello
Think about what you do.
sliderrules wrote:
SELECT TO_CHAR (DATE ' 1-1-1' + business_end_time, 'HH24:MI:SS')-TO_CHAR (DATE ' 1-1-1' + business_start_time, 'HH24:MI:SS') * 24 * 60
of time_dim
where full_date = July 1, 2013.
AND working_day = 'Y ';
The following error is returned:
ORA-01722: invalid number
The time is converted to character reslting with this error. Is there a better way to subrtacting types of data INTERVAL DAY (1) SECOND (2) (business_end_time - business_start_time)
To_char, as its name implies, returns a string of characters. You say that
TO_CHAR (...) - TO_CHAR (...) * 24 * 60
If you ask for the string returned by the 2nd TO_CHAR be multiplied by 24. Does make any sense to you?
Maybe you wanted to do the subtraction first, which would be
(TO_CHAR (...) - TO_CHAR (...)) * 24 * 60
but still would be a mistake, because you can't subtract a string to another string (or anything else).
.
Last Friday, I proposed this:
SELECT SUM (LESS (end_dt, v_end_dt)
-Most GREAT (start_dt, v_start_dt)
) * 24 * 60...
where start_dt and end_dt were the DATE in the table columns, as the value returned by TO_DATE (08 11 July 2013:45 ', "DD-Mon-YYYY HH24").
If I understand correctly, you would store stores rather 3 columns: full_date (a DATE, where the time part is 00:00:00) as well as business_start_time and business_end_time (the two INTERVAL DAY TO SECOND). In this case, you can modify the code above to say:
SELECT SUM (LESS (full_date + business_end_time, v_end_dt)
-GREATEST (full_date + business_start_time, v_start_dt)
) * 24 * 60...
You can add a DATE at an INTERVAL; the result will be a DATE. There is no need to convert anything to a data type to the other.
-
How to create a function to calculate the calendar
Oracle Forms 6i
Hai
I'm generating a daily presence that is stored in the database with the fields
Empcode, attend_date, intimate, outtime, extratime, deptcode, unitid and some other things
I need to create a function by taking these fields of the table unitid, empcode, intimate, outtime, attend_date, deptcode and return total hours he worked, and more than 8 means it will add in extra time.
If it is possible to give the run of the date value to which to this day, you must calculate.
Thanks in advance
Srikkanth.MlSrikkanth,
Depending on how you stated your RESPONDENT and OUTTIME, columns this should quite simply be a calculation. For example, if you have declared these columns as DATE columns, the following calculation should work:SELECT NVL(OUTTIME,SYSDATE) - INTIME AS hours_worked FROM DAILY_ATTENDANCE WHERE EMPCODE = "Emp Code of the employee you are evaluating";
Once you have the HOURS_WORKED, you can check if the amount is greater than 8 (or whatever is the approved duration of working hours of the employee's) to determine if he or she worked longer than their approved shift back the extra time, and the user has worked or NULL or zero if they have not exceeded their shift.
If you have set up the columns of time as something other than the DATE or DATETIME, you will need to convert the values in input/OUTPUT at a DATE so that you can use the functionality of calculation date default Oracle or you need to build your own process of calculation of the WORK_HOURS based on how you store the RESPONDENT and OUTTIME values.
I hope this helps.
Craig... -
calculate the day of the year using the date.
Hi all
Can calculate us the day of the year using the date form? Is this possible? Please help me thanks in advance
Like this
30/08/2009-30/08/2010 after calculation - 365
Sarah
Published by: SarahSarahSarah on August 30, 2009 12:49 AMSarah.
: ins1.noday must be a part of number!
Create a function in forms like this:
function get_nodays ( f_dtm_start in date, f_dtm_end in date ) return number is begin if f_dtm_start is null OR f_dtm_end is null then return ( null ); end if; return ( trunc ( f_dtm_start ) - trunc ( f_dtm_end ) ); exception when others then message ( sqlerrm || ' in function get_nodays occured.' ); return ( null ); end;
Call this function in the when-validate-point triggers on ins1. INSPERIOD and: ins1.end love
:ins1.noday := get_nodays ( :ins1.INSPERIOD, :ins1.end );
It is redundant to have the: noday as a cause of part of database
the value may by calculated every time using the values INSPERIOD and: end. -
Hello
I accessed the site earlier in the day, but when I came back to it I got the above message. Tried to access the site in IE and all worked well. Tried to disable DNS prefetch and erase history, but nothing helped. I did a virus scan but no threat detected.This problem may be caused by corrupted cookies.
Clear the cache and cookies from sites that cause problems.
"Clear the Cache":
- Tools > Options > advanced > network > storage (Cache) offline: 'clear now '.
'Delete Cookies' sites causing problems:
- Tools > Options > privacy > Cookies: "show the Cookies".
-
to calculate the days of sheets each month
Hi all
I need a query which can get leaves from an employee of days each month.
Example:
1.
If an employee has leave of date_start = 15 January 2014 ', date_end = 30 January 2014 "which is in the same month, then it will be"
Duration = 15-30 + 1 = 16 days
Total_days_in_jan = 31 days
Calculation of salary leave will be amount = (: base +: housing) * (: duration) / (Total_days_in_jan)
= (1000 + 2000) * 16/31
' 2. If his two month date_start = 15 January 2014 ', date_end = 10 February 2014.
I wrote code that works perfect below
If to_char(:date_start,'mm') = to_char(:date_end,'mm') then
v_mon_days: = TO_CHAR (last_day (TO_DATE(:date_start,'DD-MON-YYYY')), 'DD');
v_tot: = (nvl(:BASIC1,0) + nvl (:FUJ_LIVING,0)) *(:Duration_)/v_mon_days;
elsif to_char(:date_start,'mm') <>to_char(:date_end,'mm') then
v_mon_days_st_dt: = TO_CHAR (last_day(:date_start), 'DD');
v_mon_days_en_dt: = TO_CHAR (last_day(:date_end), 'DD');
v_lv_days_st_dt: = last_day(:date_start) -: date_start + 1;
v_lv_days_en_dt: =: date_end - trunc(:date_end,'mm') + 1;
v_tot_st_dt: = (nvl(:BASIC1,0) + nvl(:FUJ_LIVING,0)) * (v_lv_days_st_dt) / v_mon_days_st_dt;
v_tot_en_dt: = (nvl(:BASIC1,0) + nvl(:FUJ_LIVING,0)) * (v_lv_days_en_dt) / v_mon_days_en_dt;
v_tot: = nvl(v_tot_st_dt,0) + nvl(v_tot_en_dt,0);
end if;
Return round (v_tot);
3. If the 3 months off, say date_start = 24-may-2014 date_end = July 2, 2014.
I need some help here... what happens if the 4 month also leave...
Please suggest.
Kind regards
Afzal.
Hi Roger, Etbin
Thanks for your replies.
I found the solution on the month to display between two dates.
To calculate that I used the loop as below
declare
ST DATE: =: date_start;--TO_DATE('24-MAY-2014','DD-MON-YYYY');
ED DATE: =: date_end;--TO_DATE('02-JUL-2014','DD-MON-YYYY');
number of v_t_amount;
CURSOR C1 IS
SELECT more GRAND (ST, ADD_MONTHS (TRUNC (st, 'MONTH'), (LEVEL - 1))) dt.
LESS (ed,
LAST_DAY (ADD_MONTHS (TRUNC (st, 'MONTH'), (LEVEL - 1)))
) ld
OF THE DOUBLE
CONNECT BY LEVEL<>
MONTHS_BETWEEN (TRUNC (ed, 'MONTH'), TRUNC (st, 'MONTH'))
+ 1
ORDER BY 1;
V_AMOUNT NUMBER: = 0;
V_T_AMOUNT NUMBER: = 0;
NUMBER OF V_DAYS;
BEGIN
FOR I IN C1 LOOP
V_AMOUNT: = (nvl(:SALARY_DIFF,0) + nvl(:SPECIAL_ALLOWANCE,0) + nvl(:CF_OTHERS,0)
+ NVL(:Computer,0) + nvl(:PHONE_ALLOW,0) + nvl(:WORK_NATURAL,0)
(+ nvl(:TRANSPORTATION,0) * (i.1d - i.dt + 1) / TO_CHAR (LAST_DAY (i.1d), 'dd'));
V_T_AMOUNT: = V_AMOUNT;
end loop;
end if;
dbms_output.put_line (v_t_amount);
end;
-
Key (F2 and F3) brightness has stopped working suddenly
I use the laptop HP 15-af114AU (AMD A8 Processor). Running on Windows 10-64 bit
Its been only 2 weeks, I bought. The brightness of key i, e, f2 and f3 were working, then after a few days, I noticed it wasn't.
I tried to do it manually through the brightness on the settings option, although there was no change.
From the moment I bought this laptop, I downloaded SKYPE, Chrome and some THEMES for google Chrome.
All other funtion keys work except these.
Please help me with this problem.Hello
Try the following.
Download the AMD HD graphical installer on the following link and save it in your downloads folder.
http://ftp.HP.com/pub/SoftPaq/sp74501-75000/sp74716.exe
One when you're done, open your download folder, click with the right button on the setup of the AMD graphics card and select "Run as Administrator" to launch the installation.
When this is finished, stop the laptop.
Disconnect the power adapter and remove the battery. Press and hold the Power button for 30 seconds. Reinsert the battery and plug in the AC adapter.
Robinet tap away at the key esc that you start the computer to launch the Start Menu, and then select f10 to open the bios menu. Press f9 to load the default values (sometimes it is f5, but the menu below indicates the correct key), use the arrow keys to select 'Yes' and press ENTER. Press f10 to save the setting and still use the arrow keys to select 'Yes' and press on enter.
Start Notepad and let Windows take over completely for a few minutes before checking.
Kind regards
DP - K
-
calculate the days remaining until a given date
Hello
I am facing a problem and can not find a good solution.
I want to calculate how many days there are still up to a certain date.
It is because I want to build in a callback to the re-kalibrate hardware which is used every year.
So if it's today 05/11/2012, and the constant is 21/05/2012 labview must calculate there are still 10 days left before the re-kalibration must be finished.
Someone has any idea how to do this?
Thanks in advantage!
of course, don't forget that time stamps are DBL in seconds.
Hope this helps
-
I have two tables: employees and their departments. I'm figuring the total employees by the Department and the total employees of the entire society. I know I have to use the SUM function, but I can only calculate total employees by Department and company separately. I need to get this result:
Published by: user13675672 on January 30, 2011 14:29DEPT_NAME DEPT_TOTAL_SALARY COMPANY_TOTAL_SALARY RESEARCH 10875 29025 SALES 9400 29025 ACCOUNTING 8750 29025 This is my code: SELECT department_name, SUM(salary) as total_salary FROM employee, department WHERE employee.department_id = department.department_id GROUP BY department_name; SELECT SUM(salary) FROM employee; Can somebody help please? Thank you in advance.
Published by: user13675672 on January 30, 2011 14:31Hello
Something like:
SELECT dname, dept_tot_sal, SUM (dept_tot_sal) OVER () comp_tot_sal FROM (SELECT dname, SUM (sal) dept_tot_sal FROM dept, emp WHERE dept.deptno = emp.deptno GROUP BY dname);
There might be a smarter way, with no re - select.
Concerning
PeterAnalytical functions:
http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/functions004.htm -
How to calculate the days with 2 Date/time fields
Hello
I tried to create a workflow to update a numeric field with the following formula, however, I get an error message "value too long for the field 'ZNum_0' (maximum size 16) (SBL-DAT-00235). Can I know what is the problem with my calculation?
dtCloseDate - dtAssignDate
Thank youHi, your formula is correct.
You could be facing this problem because it will assess the value in decimal and result has no set limit for the decimal point. As digital field accept only 16 characters, the problem is occure.
You must truncate the result with a defined decimal.
Hope this will help you
Dinesh -
Calculate the number of days between two dates
Hello
Can someone help please change my formcalc script to calculate the number of working days between two date fields. My script currently calculates the total number of days between two dates, including the weekends which must be excluded from the total.
If
(HasValue (Start_Date1) & HasValue (End_Date1)) then
$
= Date2Num (End_Date1, "YYYY-MM-DD" "en_IE") - Date2Num (Start_Date1, "YYYY-MM-DD" "en_IE") + 1
on the other
""
endif
Any help will be most appreciated.
Thank you.
Check...
(1) you said that you put the script on the event «days1» calculate My sample imitates the variable names used in the original message, "Start_Date1" and "End_Date1". If the names of variables for the start and end dates are different, you will need to modify the script to account for these names.
(2) the Date2Num functions in the calculation of the "totalDays" use the date format "YYYY-MM-DD". If your date habits differ from "YYYY-MM-DD" FormCalc will complain.
Steve
-
Is there a function to get the name of the days?
Hello
I use 10.2.0.1.0 oracle
Is there a function to obtain the day of the week?
as I need to get Sunday, Monday, Tuesday, Saturday.
I know that I can use union and select the name from a double.
But I just want to know if there is another way.
I need to show 7 days in a poplist in my form, it's the requirement
Thank youSELECT TO_CHAR(TRUNC(SYSDATE ,'DAY')+Level-1,'DAY') DAYS FROM DUAL connect by Level<8 SQL> / DAYS --------- SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY
Maybe you are looking for
-
Until last night, I was able to see and edit my TC through the airport on my MBP or my iPad 2 Air utility. Now, I have received a message in the airport utility which said my TC is no longer part of my network and is no longer accessible. Time backup
-
I installed Ad Block some time ago and it is true that I do not have ads popping up all the time. Someone advised me that I should not have because it is to let these people have access to his computer. I'd be suspicious of Ad Block, and if yes, how
-
I tried to use a midi keyboard M-Audio Keystation 49th with my Tecra A6. The keyboard is supposed to be plug-and-play, and when I plug it in it seems to be doing things of ritgh, through a sort of a setup process, and then run properly in the list of
-
Original title: error message: When I try to open one of my programs, I get an error message states that my program has stopped working, Windows is looking for a solution
-
OfficeJet 6700 Premium does not print
HI - need help please! I completely installed, configure printer, a recognized/connected on network etc. The laptop is to see the device and I have added the printer. However - it is not print? Ideas? Thank you Charlotte