(comments are locked)
|
|
In SQL Server I would use a case statement, not sure exactly what you would use in Oracle, but maybe this might give you an idea..... This should work in Oracle 9 or better except the <> might be better off spelled as != and the word and is removed after where. In case if the Oracle version is 8 or older then case is not available, but decode is, so for older Oracle, this should do it: select
sum(decode(company_person_all.citizenship,
'SAUDI ARABIA', 0, 1)) as TOTAL_NSaudi,
sum(decode(company_person_all.citizenship,
'SAUDI ARABIA', 1, 0)) as TOTAL_Saudi,
sum(1) as Total_All
from company_person_all
where
company_person_all.employee_status = 'Active'Oleg
Feb 28 '12 at 08:14 PM
Oleg
thank Kev & oleg for your support mate, but i need one more thing, to track employment in current month by give prompt to enduser from "IFSAPP.EMP_EMPLOYED_TIME_ROW" say the only In employee at that month
Feb 29 '12 at 06:45 AM
bandder
Can you please add more details in the question, like what query you already have. Thanks.
Feb 29 '12 at 07:05 AM
Usman Butt
here the query from IFSAPP.EMP_EMPLOYED_TIME_ROW 1 126 10 000368 5/1/2009 12/31/9999 Full Time - Open Contract 1 129 10 000369 5/1/2011 7/1/2012 Full Time - Open Contract 1 131 10 000370 5/1/2009 12/31/9999 Full Time - Open Contract 1 133 10 000371 5/23/2009 12/31/9999 Full Time - Open Contract i just need to add this statement to the one that Kav giving me so i can get track employment in current month by give prompt to enduser
Feb 29 '12 at 07:20 AM
bandder
HERE THE STATEMENT THAT I NEED TO FIX
SELECT to_char(SYSDATE, 'MONTH') AS "CURRENT MONTH",
COUNT(CASE
WHEN citizenship 'SAUDI ARABIA' THEN
1
END) AS TOTAL_NON_Saudi,
COUNT(CASE
WHEN citizenship = 'SAUDI ARABIA' THEN
1
END) AS TOTAL_Saudi,
COUNT(*) AS Total_All
FROM company_person_all
WHERE (company_person_all.citizenship != 'SAUDI ARABIA' OR
company_person_all.citizenship = 'SAUDI ARABIA')
AND company_person_all.employee_status = 'Active'
Feb 29 '12 at 07:47 AM
bandder
(comments are locked)
|
|
The best would have been adding a sample data, output you need, tables fields and their relationships.
Feb 29 '12 at 09:10 AM
Sacred Jewel
SELECT to_char(SYSDATE, 'MONTH') AS "CURRENT MONTH", SUM(CASE WHEN a.citizenship <> 'SAUDI ARABIA' THEN 1 ELSE 0 END ) AS TOTAL_NON_Saudi, SUM(CASE WHEN a.citizenship = 'SAUDI ARABIA' THEN 1 ELSE 0 END ) AS TOTAL_Saudi, SUM(1) AS Total_All FROM company_person_all a JOIN IFSAPP.EMP_EMPLOYED_TIME_ROW T ON a.emp_no = t.emp_no AND SYSDATE between t.date_of_employment and t.date_of_leaving WHERE a.employee_status = 'Active' what i need rigt know is to get total form TOTAL_NON_Saudi+TOTAL_Saudi with same statemnt see attachment for more info
Feb 29 '12 at 01:42 PM
bandder
(comments are locked)
|
|
What about this
(comments are locked)
|
|
it just give me "total all" what about the "month" & "non_saudi" & "saudi" i need it as what shown on the screen shot thank you again for your help
(comments are locked)
|



