Oracle query problem
Dear All,
i have to calulate percentage of attendence having a mannual flag i.e. 'Y' on datewise and sum up it with all existing dates and then devide it by no of all distinct date in a month for ex..
*percentage=
.......... Count no of attandence having ismannual flag set to be 'Y' on particular date
SUM( ---------------------------------------------------------------------------------------------------------------*100)/Count(Distinct date in a month for a particular department)
........... count total no of candidate present on particular date*
i have to calculate pertantage for each distinct department availabel in table tbltimeregister1
for this i m trying query..
select
DEPARTMENTCODE,sum(sum(decode(ismannual,'Y',1,0))/count(paycode)*100)/COUNT(DISTINCT DATEOFFICE)
from tbltimeregister1
where to_char(dateoffice,'MM/YYYY')='03/2013'
GROUP BY (DEPARTMENTCODE,DATEOFFICE)but it display error not a single group fuction
pl tell me how to calculate it for all the distinct department
with regards
vishal agrawal
Please consider the following when you post a question. This would help us help you better
1. New features keep coming in every oracle version so please provide Your Oracle DB Version to get the best possible answer.
You can use the following query and do a copy past of the output.
select * from v$version 2. This forum has a very good Search Feature. Please use that before posting your question. Because for most of the questions
that are asked the answer is already there.
3. We dont know your DB structure or How your Data is. So you need to let us know. The best way would be to give some sample data like this.
I have the following table called sales
with sales
as
select 1 sales_id, 1 prod_id, 1001 inv_num, 120 qty from dual
union all
select 2 sales_id, 1 prod_id, 1002 inv_num, 25 qty from dual
select *
from sales 4. Rather than telling what you want in words its more easier when you give your expected output.
For example in the above sales table, I want to know the total quantity and number of invoice for each product.
The output should look like this
Prod_id sum_qty count_inv
1 145 2 5. When ever you get an error message post the entire error message. With the Error Number, The message and the Line number.
6. Next thing is a very important thing to remember. Please post only well formatted code. Unformatted code is very hard to read.
Your code format gets lost when you post it in the Oracle Forum. So in order to preserve it you need to
use the {noformat}{noformat} tags.
The usage of the tag is like this.
<place your code here>\
7. If you are posting a *Performance Related Question*. Please read
{thread:id=501834} and {thread:id=863295}.
Following those guide will be very helpful.
8. Please keep in mind that this is a public forum. Here No question is URGENT.
So use of words like *URGENT* or *ASAP* (As Soon As Possible) are considered to be rude.
Similar Messages
-
Converting MS SQL Server Query to Oracle Query
Hi There,
I've a strange problem. My project uses both MS SQL Server and Oracle server at run time. I've lot of queries which are written in MS SQL Style. Now, iam planning to write a helper class whic converts MS SQL Query to Oracle Query. Please Help me if any one has that kind of Helper with you.
Thanks And Regards,
Sasi KanthThat is why persistence applications like Hibernate or
CMP get used for apps that will use more than one DB,
but it takes upfront planning.
If you have a set of automated unit tests that work
with SQL Server, they will be a big help in getting
your Oracle code up and running.Indeed - JUnit and Ant would be a big help here.
It sounds like you have SQL in your JSPs, that will
work against you as well if so. If you are using a
DAO pattern, this will be much easier, as you can
re-implement each DAO for Oracle.If you'd layered this app properly, you might just implement an OracleDAOFactory and be done with it. Interfaces and a DAO layer would go a long way.
This is why layering is such a good idea. It isolates changes in a smaller subset of classes.
But your problem sounds pretty big. It'd be daunting even if it were well designed. -
Some diffrence in oracle query and mysql query
sir i see both query in SessionBean1
mysql query
SELECT ALL usert.username,
usert.userid,
usert.camid FROM usert
this not use user name
oracle query
SELECT ALL MFA.LUSER.USERID,
MFA.LUSER.TITLE,
MFA.LUSER.CAMPID,
MFA.LUSER.PWD,
MFA.LUSER.USERNAME
FROM MFA.LUSER
the user name mfa is use in this query you can see
this is main diffrence
but i yse both in code but not get result
try {
RowKey userRowKey = luserDataProvider.findFirst
(new String[] { "MFA.LUSER.USERNAME" },
new Object[] { textField4.getText()});
if (userRowKey == null) {
textField3.setText("11111");
return null;
} else {
textField3.setText("22222");
return null;
catch (Exception e) {
log("Cannot perform login for userid " + textField3.getText(), e);
error("Cannot perform login for userid " + textField3.getText() + ": " + e);
textField3.setText("77777");
return null;
problem in only oracle not in mysql
please give me idea how i get result
thank youcan you post your query with explain plan for both 9i version and 10g version.
Thanks,
karthick. -
Query on using Variables in Oracle Query
Hi
i am new to Oracle, i have tried extracting data from the Oracle Database using the following Query which includes 1 variable SYSDATE_UTS, however when i try to execute the Query i get an error. Please let me know what am i doing wrong and how can i correct it.
Error Message
ORA-06550: line 4, column 1:
PLS-00428: an INTO clause is expected in this SELECT statement
Oracle Query
DECLARE SYSDATE_UTS NUMBER := (sysdate-to_date('19700101','yyyymmdd'))*86400;
BEGIN
SELECT
INCIDENT_NUMBER,
to_date(to_char((1/86400*REPORTED_DATE)+to_date('19700101','yyyymmdd'),'mm/dd/yyyy hh24:mi:ss'),'mm/dd/yyyy hh24:mi:ss') as REPORTED_DATE_TIME,
,GROUP_TRANSFERS
,LAST_MODIFIED_BY
,to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * LAST_MODIFIED_DATE,'mm/dd/yyyy hh24:mi:ss'),'mm/dd/yyyy hh24:mi:ss') as LAST_MODIFIED_DATE
,(to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) as AGE
,CASE
WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) BETWEEN 0 AND 1 THEN '0-1 Days'
WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * SYSDATE_UTS, 'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) BETWEEN 2 AND 4 THEN '2-4 Days'
WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) BETWEEN 5 AND 9 THEN '5-9 Days'
WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) BETWEEN 10 AND 19 THEN '10-19 Days'
WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) >20 THEN '20+ Days'
ELSE 'UNKNOWN'
END AS AGE_GROUP
FROM IncidentDataBase
and STATUS not in (4,5,6)
and rownum <10;
END;Hi Frank
i am using the following Oracle Version
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
CORE 10.2.0.5.0 Production
TNS for Linux: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production
and Quest Toad for Oracle to write and execute the queries:
Toad for Oracle Xpert
Version 10.1.1.8
The code i am using is:
variable SYSDATE_UTS NUMBER;
exec SYSDATE_UTS := (sysdate-to_date('19700101','yyyymmdd'))*86400;
SELECT
INCIDENT_NUMBER,
to_date(to_char((1/86400*REPORTED_DATE)+to_date('19700101','yyyymmdd'),'mm/dd/yyyy hh24:mi:ss'),'mm/dd/yyyy hh24:mi:ss') as REPORTED_DATE_TIME
,GROUP_TRANSFERS
,LAST_MODIFIED_BY
,to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * LAST_MODIFIED_DATE,'mm/dd/yyyy hh24:mi:ss'),'mm/dd/yyyy hh24:mi:ss') as LAST_MODIFIED_DATE
,(to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * :SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) as AGE
,CASE
WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * :SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) BETWEEN 0 AND 1 THEN '0-1 Days'
WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * :SYSDATE_UTS, 'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) BETWEEN 2 AND 4 THEN '2-4 Days'
WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * :SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) BETWEEN 5 AND 9 THEN '5-9 Days'
WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * :SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) BETWEEN 10 AND 19 THEN '10-19 Days'
WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * :SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) >20 THEN '20+ Days'
ELSE 'UNKNOWN'
END AS AGE_GROUP
FROM IncidentDataBase
WHERE STATUS not in (4,5,6)
and rownum <10;
Notes:
1. When i put the cursor before "variable" (starting of the query) and execute the script i get an Error: ORA-00900: invalid SQL statement.
2. When i put the cursor just before "SELECT" i get a pop up.
a. it is a Toad window which displays the available variables (in this case :SYSDATE_UTS).
b. gives me a dropdown option to select the type (by default VARCHAR2 is selected).
c. there is a value field where i need to enter the value for the Variable.
d. the SQL statement shown in this dilog box does not include the 1st 2 lines
variable SYSDATE_UTS NUMBER;
exec SYSDATE_UTS := (sysdate-to_date('19700101','yyyymmdd'))*86400;
Q: is there something wrong in the syntax i am using?
Sven W. - I have been using your method all these days, which works just fine. i wanted to know how i could use a variable instead.
Business Requirement - My whole intent is to calculate the Age of an incident (Difference between "Reported Date" and current date) and to assign Age Groups (0-1 Days, 2-4 Days,....,20+ Days).
Edited by: 921713 on Mar 19, 2012 12:23 PM -
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
Report Builder 10.1.2.0.2
ORACLE Server Release 10.1.0.4.2
Oracle Procedure Builder 10.1.2.0.2
Oracle ORACLE PL/SQL V10.1.0.4.2 - Production
Oracle CORE 10.1.0.4.0 Production
Oracle Tools Integration Services 10.1.2.0.2
Oracle Tools Common Area 10.1.2.0.2
Oracle Toolkit 2 for Windows 32-bit platforms 10.1.2.0.2
Resource Object Store 10.1.2.0.2
Oracle Help 10.1.2.0.2
Oracle Sqlmgr 10.1.2.0.2
Oracle Query Builder 10.1.2.0.2 - Production
PL/SQL Editor (c) WinMain Software (www.winmain.com), v1.0 (Production)
Oracle ZRC 10.1.2.0.2
Oracle XML Developers Kit 10.1.0.4.2 - Production
Oracle Virtual Graphics System 10.1.2.0.2
Oracle Image 10.1.2.0.2
Oracle Multimedia Widget 10.1.2.0.2
Oracle Tools GUI Utilities 10.1.2.0.2
I have enclosed sample data and also table structure. I need help in getting the query.
select dept_id,proc_code,override_goal,goal_override_date
from table2
where goal_override_date between '02-jan-2014' and '11-jan-2014'
and dept_id = 10
and proc_code = 'CP'
select DEPT_ID, PROC_CODE, DAY_SUNDAY, DAY_MONDAY,
DAY_TUESDAY, DAY_WEDNESDAY, DAY_THURSDAY,
DAY_FRIDAY, DAY_SATURDAY
from table1
where dept_id =10
and proc_code = 'CP';
Table1 is kind of maintenance table.
In Table2 values can be overridden.
Requirement
Check to see if there is data in table 2 for the date range . If table2 has no value then take value from table1 for that day the date falls into. Any more clarification please ask me.
Sundays are all zeros.
I want this data. and the sum for the date range.
2-jan-2014 - 3
3-jan-2014 - 3
4-jan-2014 - 3
5-jan-2014 - 0
6-jan-2014 - 1
7-jan-2014 - 3
8-jan-2014 - 5
9-jan-2014 - 5
10-jan-2014 - 3
11-jan-2014 - 3
Sum for the date range has to be 29
Sample table and data
CREATE TABLE TABLE1
DEPT_ID NUMBER NOT NULL,
PROC_CODE VARCHAR2(2 BYTE) NOT NULL,
DAY_SUNDAY NUMBER(4) NOT NULL,
DAY_MONDAY NUMBER(4) NOT NULL,
DAY_TUESDAY NUMBER(4) NOT NULL,
DAY_WEDNESDAY NUMBER(4) NOT NULL,
DAY_THURSDAY NUMBER(4) NOT NULL,
DAY_FRIDAY NUMBER(4) NOT NULL,
DAY_SATURDAY NUMBER(4) NOT NULL
Insert into TABLE1
(DEPT_ID, PROC_CODE, DAY_SUNDAY, DAY_MONDAY, DAY_TUESDAY,
DAY_WEDNESDAY, DAY_THURSDAY, DAY_FRIDAY, DAY_SATURDAY)
Values
(10, 'CP', 0, 3, 3,
3, 3, 3, 3);
COMMIT;
CREATE TABLE TABLE2
DEPT_ID NUMBER NOT NULL,
PROC_CODE VARCHAR2(2 BYTE) NOT NULL,
OVERRIDE_GOAL NUMBER(4),
GOAL_OVERRIDE_DATE DATE NOT NULL
Insert into TABLE2
(DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
Values
(10, 'CP', 1, TO_DATE('01/06/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into TABLE2
(DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
Values
(10, 'CP', 3, TO_DATE('01/07/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into TABLE2
(DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
Values
(10, 'CP', 5, TO_DATE('01/08/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into TABLE2
(DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
Values
(10, 'CP', 5, TO_DATE('01/09/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into TABLE2
(DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
Values
(10, 'CP', 3, TO_DATE('01/10/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into TABLE2
(DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
Values
(10, 'CP', 3, TO_DATE('01/11/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
COMMIT;
Help is highly appreciated.SELECT dates,
override_goal,
SUM(override_goal) OVER()
FROM(SELECT dates,
CASE WHEN EXISTS(SELECT 1
FROM table2 t2
WHERE t2.goal_override_date = qry1.dates
AND t2.dept_id = 10
AND t2.proc_code = 'CP')
THEN (SELECT override_goal
FROM table2 t2
WHERE t2.goal_override_date = qry1.dates
AND t2.dept_id = 10
AND t2.proc_code = 'CP')
ELSE (SELECT DECODE(days,'SUN',day_sunday,
'MON',day_monday,
'TUE',day_tuesday,
'WED',day_wednesday,
'THU',day_thursday,
'FRI',day_friday,
'SAT',day_saturday )
FROM table1)
END as override_goal
FROM (SELECT in_dt1+(LEVEL-1) dates,
TO_CHAR(in_dt1+(LEVEL-1),'DY') days
FROM(SELECT TO_DATE(&from_date,'DD-MON-YYYY') in_dt1,
TO_DATE(&to_date,'DD-MON-YYYY') in_dt2
FROM dual)
CONNECT BY LEVEL <= (in_dt2 - in_dt1)+1) qry1);
Now run the query it will prompt you for the inputs. You can pass the date values and check the result. Otherwise replace &from_date,&to_date with user inputs -
How to enforce index in oracle query
Hi all
how to enforce index in oracle query
RegardsUse INDEX hint to force Optimizer to use the specfied index.
You really need to investigate why Optimizer doesn't choose the index. Remember, INDEX SCAN are not always GOOD.
Jaffar -
Oracle reports problem in distribution with xml file
Hi ,
I am having problem while I am trying to distribute the file with specifing the destination details in the xml. If I am giving the destination details in url then it is working.
Ex.
This is Working
http://bryxh91:8889/reports/rwservlet?report=devlopersuit/reports/test.jsp&userid=anju/[email protected]&desformat=pdf&destype=file&desname=devlopersuit/reports/output_file.pdf
Not working :
http://bryxh91:8889/reports/rwservlet?report=devlopersuit/reports/test.jsp&userid=anju/[email protected]&DISTRIBUTE=YES&destination=devlopersuit/reports/dis_test.xml
xml file
<destinations>
<file id="test" name="output_file.pdf" format="pdf">
<include scr="mainSection"/>
</file>
</destinations>
Error : REP-34304: Distribution failed to complete; review the distribution lists
Its been week I tried many things , but not working.
Right now I am trying to distribute to single file but my goal is to burst and distribute on basis of account number.
This is the first stage of the project.
Thanks a lot for the help
AnjuHello
see answer in Oracle reports problem in distribution with xml file
Regards -
Passing parameters to oracle query
Hi Everyone,
I'm a newbie to oracle and need help passing parameters to an oracle query. For example, I need to show all the employees in a certain department.So a list of "DEPT_CODE"'s will be displayed on a webpage and then the selected value will be passed to the query. I currently have this query in MS Access and use the bracket for user input ("[Dept]"). But how can this be done in oracle?
I am using ASP.NET 2.0 and Crystal Reports XI. Basically I have a webform where users can select the date range and department from a listbox. When the submit button is clicked, the values are passed to the query in crystal reports. For example, I have a query with "DEPT" as a parameter. So I pass the value of the selected listbox item from the webform to the crystal report. But now I have to select data from an oracle database and provide parameters. This is where I need help.
Thanks in advance
-SamDuplicate post.
Refer to this thread
Passing parameters to oracle query -
Hi,
I need to run an Oracle query with the following fields in the AWR report:
First Query:
DB Name
Begin Snap Time
End Snap Time
Begin Snap
End Snap
Event
Waits
Time(s)
Avg wait (ms)
% DB time
Wait Class
Second Query:
DB Name
Begin Snap Time
End Snap Time
Begin Snap
End Snap
Elapsed Time (s)
Executions
Elapsed Time per Exec(s)
%Total
%CPU
%IO
SQL Id
SQL Module
SQL Text
How Can I write this query?
Thanks in advance!R.Royal wrote:
Thanks,
I know how to generate an AWR report but I would like to write a query that takes these fields from oracle views. (DBA_ or V$)
And the link I sent to you shows you the views required to do that.
Cheers, -
Oracle query hints in JPQL - is it possible?
Sorry, posted to wrong forum... I don't know how to delete it - only edit...
Hello,
I am using Sun Java Application Server 9.1 (GlassFish), EJB 3.0 and JPA (TopLink). My database is Oracle.
Is there any way to specify Oracle query hints (for example, /*+ rule */ in JPQL queries? Or the only way to do it is using native queries?
Many thanks in advance
Edited by: Troff_2 on Nov 27, 2007 5:50 AMYes.It is possible.Only need to modify the view for order tracker query need to change.
You can use decode statement in the query to add status as Processing .
Please refer the IBE_ORDER_SUM_V view for details.
Eg:
decode(oel.meaning,'Booked',"Processing",oel.meaning) from
oe_lookups
oel, -
Hello APEX people,
I posted my problem here:
Designing LOV Query Problem
What I have is a sequence like this:
CREATE SEQUENCE
DR_SEQ_FIRST_SCHEDULE_GROUP
MINVALUE 1 MAXVALUE 7 INCREMENT BY 1 START WITH 1
CACHE 6 ORDER CYCLE ;
What I need would be a SQL query returning all possible values oft my sequence like:
1
2
3
4
5
6
7
I want to use it as a source for a LOV...
The reason why I use the cycling sequence is: My app uses it to cycle scheduling priorities every month to groups identified by this number (1-7).
In the Admin Form, I want to restrict the assignment in a user friendly way - a LOV.
Thanks
JohannHere ist the solution (posted by michales in the PL/SQL forum):
SQL> CREATE SEQUENCE
dr_seq_first_schedule_group
MINVALUE 1 MAXVALUE 7 INCREMENT BY 1 START WITH 1
CACHE 6 ORDER CYCLE
Sequence created.
SQL> SELECT LEVEL sn
FROM DUAL
CONNECT BY LEVEL <= (SELECT max_value
FROM user_sequences
WHERE sequence_name = 'DR_SEQ_FIRST_SCHEDULE_GROUP')
SN
1
2
3
4
5
6
7
7 rows selected. -
SQL+-MULTI TABLE QUERY PROBLEM
HAI ALL,
ANY SUGGESTION PLEASE?
SUB: SQL+-MULTI TABLE QUERY PROBLEM
SQL+ QUERY GIVEN:
SELECT PATIENT_NUM, PATIENT_NAME, HMTLY_TEST_NAME, HMTLY_RBC_VALUE,
HMTLY_RBC_NORMAL_VALUE, DLC_TEST_NAME, DLC_POLYMORPHS_VALUE,
DLC_POLYMORPHS_NORMAL_VALUE FROM PATIENTS_MASTER1, HAEMATOLOGY1,
DIFFERENTIAL_LEUCOCYTE_COUNT1
WHERE PATIENT_NUM = HMTLY_PATIENT_NUM AND PATIENT_NUM = DLC_PATIENT_NUM AND PATIENT_NUM
= &PATIENT_NUM;
RESULT GOT:
&PATIENT_NUM =1
no rows selected
&PATIENT_NUM=2
no rows selected
&PATIENT_NUM=3
PATIENT_NUM 3
PATIENT_NAME KKKK
HMTLY_TEST_NAME HAEMATOLOGY
HMTLY_RBC_VALUE 4
HMTLY_RBC_NORMAL 4.6-6.0
DLC_TEST_NAME DIFFERENTIAL LEUCOCYTE COUNT
DLC_POLYMORPHS_VALUE 60
DLC_POLYMORPHS_NORMAL_VALUE 40-65
ACTUAL WILL BE:
&PATIENT_NUM=1
PATIENT_NUM 1
PATIENT_NAME BBBB
HMTLY_TEST_NAME HAEMATOLOGY
HMTLY_RBC_VALUE 5
HMTLY_RBC_NORMAL 4.6-6.0
&PATIENT_NUM=2
PATIENT_NUM 2
PATIENT_NAME GGGG
DLC_TEST_NAME DIFFERENTIAL LEUCOCYTE COUNT
DLC_POLYMORPHS_VALUE 42
DLC_POLYMORPHS_NORMAL_VALUE 40-65
&PATIENT_NUM=3
PATIENT_NUM 3
PATIENT_NAME KKKK
HMTLY_TEST_NAME HAEMATOLOGY
HMTLY_RBC_VALUE 4
HMTLY_RBC_NORMAL 4.6-6.0
DLC_TEST_NAME DIFFERENTIAL LEUCOCYTE COUNT
DLC_POLYMORPHS_VALUE 60
DLC_POLYMORPHS_NORMAL_VALUE 40-65
4 TABLES FOR CLINICAL LAB FOR INPUT DATA AND GET REPORT ONLY FOR TESTS MADE FOR PARTICULAR
PATIENT.
TABLE1:PATIENTS_MASTER1
COLUMNS:PATIENT_NUM, PATIENT_NAME,
VALUES:
PATIENT_NUM
1
2
3
4
PATIENT_NAME
BBBB
GGGG
KKKK
PPPP
TABLE2:TESTS_MASTER1
COLUMNS:TEST_NUM, TEST_NAME
VALUES:
TEST_NUM
1
2
TEST_NAME
HAEMATOLOGY
DIFFERENTIAL LEUCOCYTE COUNT
TABLE3:HAEMATOLOGY1
COLUMNS:
HMTLY_NUM,HMTLY_PATIENT_NUM,HMTLY_TEST_NAME,HMTLY_RBC_VALUE,HMTLY_RBC_NORMAL_VALUE
VALUES:
HMTLY_NUM
1
2
HMTLY_PATIENT_NUM
1
3
MTLY_TEST_NAME
HAEMATOLOGY
HAEMATOLOGY
HMTLY_RBC_VALUE
5
4
HMTLY_RBC_NORMAL_VALUE
4.6-6.0
4.6-6.0
TABLE4:DIFFERENTIAL_LEUCOCYTE_COUNT1
COLUMNS:DLC_NUM,DLC_PATIENT_NUM,DLC_TEST_NAME,DLC_POLYMORPHS_VALUE,DLC_POLYMORPHS_
NORMAL_VALUE,
VALUES:
DLC_NUM
1
2
DLC_PATIENT_NUM
2
3
DLC_TEST_NAME
DIFFERENTIAL LEUCOCYTE COUNT
DIFFERENTIAL LEUCOCYTE COUNT
DLC_POLYMORPHS_VALUE
42
60
DLC_POLYMORPHS_NORMAL_VALUE
40-65
40-65
THANKS
RCS
E-MAIL:[email protected]
--------I think you want an OUTER JOIN
SELECT PATIENT_NUM, PATIENT_NAME, HMTLY_TEST_NAME, HMTLY_RBC_VALUE,
HMTLY_RBC_NORMAL_VALUE, DLC_TEST_NAME, DLC_POLYMORPHS_VALUE,
DLC_POLYMORPHS_NORMAL_VALUE
FROM PATIENTS_MASTER1, HAEMATOLOGY1, DIFFERENTIAL_LEUCOCYTE_COUNT1
WHERE PATIENT_NUM = HMTLY_PATIENT_NUM (+)
AND PATIENT_NUM = DLC_PATIENT_NUM (+)
AND PATIENT_NUM = &PATIENT_NUM;Edited by: shoblock on Nov 5, 2008 12:17 PM
outer join marks became stupid emoticons or something. attempting to fix -
Is there try and catch in oracle query ?
hi
is there try and catch in oracle query ?
try
do some update
catch
if there was error go to here
}>
is there try and catch in oracle query ?
>
Yes - except it uses BEGIN --- EXCEPTION --- END where BEGIN replaces the try and EXCEPTION replaces the catch.
BEGIN
-- Calculation might cause division-by-zero error.
pe_ratio := stock_price / net_earnings;
dbms_output.put_line('Price/earnings ratio = ' || pe_ratio);
EXCEPTION -- exception handlers begin
-- Only one of the WHEN blocks is executed.
WHEN ZERO_DIVIDE THEN -- handles 'division by zero' error
dbms_output.put_line('Company must have had zero earnings.');
pe_ratio := null;
WHEN OTHERS THEN -- handles all other errors
dbms_output.put_line('Some other kind of error occurred.');
pe_ratio := null;
END; -- exception handlers and block end here
/The multiple WHEN conditions correspond to using multiple 'catch' statements in Java. -
Everyones Oracle Linux Problem solved!!!
Everyones Oracle Linux Problem solved!!!
Here's something Linux people should relate to: Use what works!
what works?
NT works! NT works great with 8i AND OAS.
No hassles at all!
Up and running within one day!!!!
Guaranteed!
U don't see a NT forum here with people having ridiculous install problems like Linux people?
Perhaps Oracle should moderate this newsgroup and even give an authorative answer or two?
nullI have switched our development and soon production databases to Linux because it runs like a charm. Fast and efficient, no problems. The installer has been a problem no doubt because Oracle put less of an emphasis on debugging their Linux installer than their idiot-proof NT installer.
By the way, I was able to circumvent installer problems by just linking svrmgrl to svrmgrlO; this avoided the dreaded segmentation fault and kicked everything open just fine.
BTW, about NT; what makes an OS is not how well everything works when everything is going well, but how bad it gets when something goes bad. For instance, the segmentation faults on Linux weren't a problem because I just picked up and continued; on NT you'd have to restart the whole system...not a pleasant feature.
null -
Oracle Query runs very slow filling table
I have used Java Studio Creator 2 with Sun Java System Application Server Platform Edition 8.1_02 (build b06-fcs) in the past. I created a simple oracle query to populate a table and displaying about 560 rows in a table via a web browser. This runs excellent.
Now, I use Netbeans 6, along with Sun Java System Application Server 9.1 (build b58g-fcs), I populate a table using the same query as before and it takes quite a long time to fill the table. Actually, the browser keeps asking if I want to stop the script about 6 times. If I keep saying yes, it eventually completes.
I'm using an Oracle 9i database and have tried different drivers from Oracle with the same results.
Any idea why the difference in filling the table or how to correct this? Thanks!
Please note: I have this same question posted in the Java.net forums but it's not been answered so far, I hope this isn't crossposting and I get yelled at!for NetBeans questions I suggest posting your question in the [email protected] For more information:
http://www.netbeans.org/community/index.html
Maybe you are looking for
-
Playbook crashes network when using 80211N networks
Hi. I am having issue getting my PB to work correctly on 80211N networks. I have tried with both a generic DLink router and a brand new LinksysWRT310 router. My configuration is Siemens SE567 Modem/Router with an uplink to my Wifi/Lan network. When I
-
Install of iLife 11 leaves iPhoto 09
Tried deleting 09 apps from Finder and then installed iLife 11 disc. It left iPhoto and says it won't fun on Mavericks (even if it did, I want all the new apps!). I tried to delete it again and I did a custom install of just iPhoto 11 (it had a - ne
-
I have 2 separate issues that I am having problems with-one being and online game and one being wanting to UNinstall the add on I have put on my PC. Both issues are requiring me to use the "tools" bar and I CANNOT find it!! I have looked my page over
-
Accordion flickers with Flash content
I think this is a known bug for accordion but I haven't seen any solution for this yet. The problem is accordion flickers if you have Flash content inside the div, if it's just text, then it is ok. This happens on all major browser including Firefox,
-
Hi all, I have just recieved a file of photo's that won't show when I open it up in Quicktime 7.2. The music is playing, but no photo's show. The file has a .wmv at the end. Does anybody have any idea's on how to fix this prob? I've also attempted to