Select query output needed
Hi
SELECT CUREPRESS,PRODUCTIONCODE,YYYYMMDD STARTDATE,
CASE
WHEN SCHEDULE1 = 0 AND SCHEDULE2 = 0 AND SCHEDULE3 >0 AND ROUND(30-SCHEDULE3/CURECAPACITY*24,0)>24 THEN
ROUND(30-(SCHEDULE3/CURECAPACITY*24),0)-24
WHEN SCHEDULE1 = 0 AND SCHEDULE2 = 0 AND SCHEDULE3 >0 AND ROUND(30-SCHEDULE3/CURECAPACITY*24,0)<=24 THEN
ROUND(30-SCHEDULE3/CURECAPACITY*24,0)
WHEN SCHEDULE1 = 0 AND SCHEDULE2 >0 AND SCHEDULE3 >0 THEN
ROUND(22-SCHEDULE2/CURECAPACITY*24,0)
WHEN SCHEDULE1 > 0 AND SCHEDULE2 >0 AND SCHEDULE3 >0 THEN
ROUND(14-SCHEDULE1/CURECAPACITY*24,0)
END STARTDATE1
FROM (
SELECT curepress,PRODUCTIONCODE,YYYYMMDD,schedule1,schedule2,schedule3,curecapacity
FROM ORGCURESCHEDULEDAY A
WHERE YYYYMMDD = (SELECT MIN(YYYYMMDD)
FROM ORGCURESCHEDULEDAY B
WHERE A.PRODUCTIONCODE=B.PRODUCTIONCODE
AND A.CUREPRESS =B.CUREPRESS )
)GROUP BY PRODUCTIONCODE,CUREPRESS,YYYYMMDD,SCHEDULE1,SCHEDULE2,SCHEDULE3,CURECAPACITY
ORDER BY CUREPRESS,PRODUCTIONCODE
The above query gives 4 column values like..!!
curepress productioncode startdate startdate1
0101 IO72A 20110412 22 -------> case statement gives this value as startdate1
0101 OQ36A 20110221 6
I want to display the output like startdate1 as (startdate + statedate1)
curepress productioncode startdate startdate1
0101 IO72A 20110412 20110412 22.00
0101 OQ36A 20110221 20110221 06.00
please help me ...!!
regards
Karanam
Please don't duplicate your questions.
select query giving error
Locking this thread.
Similar Messages
-
How to store select query output in arrays.
i created a varray type variables and now want to assign some data though select query output in pl/sql code as well as in reports 6i.
You're in the wrong forum (this one is for issues with the SQL Developer tool). You were in the right one where you posted first, but don't reuse unrelated threads as you did.
Regards,
K. -
Select query output as a separate column
Hi,
How to represent the different values in the same table column as an output in the separate columns using the select query ?
For example,
Table "A" has column "col1"
col1 contains values as below:
col1
====
1
2
3
4
5
now want to display the above column values as a separate column as the output.
col_alias1 col_alias2 col_alias3 col_alias4 col_alias5
1 2 3 4 5
How it can be done ?
Regards
Edited by: user640001 on Jan 31, 2011 11:19 PMHi,
You can try something mentioned in this link.
http://www.oracle-base.com/articles/misc/StringAggregationTechniques.php
or try this
with t as (
select 'PID12' as product_id, 1 as status_id, 'Time1' as time from dual union all
select 'PID13', 2, 'Time2' as time from dual union all
select 'PID14', 3, 'Time3' as time from dual)
select min(case when status_id = 1 then product_id || ' ' || time end) as Recieved, min(case when status_id = 2 then product_id || ' ' || time end) as Accepted,
min(case when status_id = 3 then product_id || ' ' || time end) as Delivered from tcheers
VT
Edited by: VT on Feb 1, 2011 5:28 PM -
CohQL command line Tool select query output in file (unix)
Ho to insert Coherence CohQL command line Tool select query result in file in unix platform. I have tried below query but failed
query.cmd -s -c -l "select * from 'dist-example'" >myOutput.txt
I also tried below query, result is displayed in command line but no file is created in folder.
select * from dist-example >myOutput.txt
I also tried one more query, result is displayed in command line but no file is created in folder.
select * from dist-example >/opt/bin/myOutput.txtHi,
In Unix you should use query.sh instead of query.cmd
In your case then the command would be smething like:
query.sh -s -c -l "select * from 'dist-example'" >myOutput.txt
You can also try using '>>' instead of '>' in order to redirect to a text file.
Hope this helps.
-Cris -
Select Query Problem-need help
hi,
Help me out from this problem.
Actually i have a table and the data in it as follows:
Department Name Job Name
Accounts Sr. Accountant
Accounts Jr. Accountant
Accounts Cleark
But i dont want the repeated Department Name.. and i want the same output as follows.
Department Name Job Name
Accounts Sr. Accountant
Jr. Accountant
Cleark
Without using sql reports and Sql Plus additional commands.
The same output should come from a sql query only.
Thanks in Advance
Md Anwer AliI shouldn't try to code before I have had at least three cups of coffee. The actual answer is:
select decode(department,lag(department) over (order by department),null,department)
, job
from departments
order by department.
I ran this:
select decode(job,lag(job) over (order by job),null,job)
, ename
from emp
order by job
and got this result:
SQL> /
DECODE(JO ENAME
ANALYST SCOTT
FORD
CLERK SMITH
ADAMS
MILLER
JAMES
MANAGER JONES
CLARK
BLAKE
PRESIDENT KING
SALESMAN ALLEN
MARTIN
TURNER
WARD
14 rows selected. -
Spool SELECT query output in unix
Dear All,
I have a requirement to spool out the data from a table into a log file and send it as an email.
In my unix shell script, this is what I am doing:
set def off;
set echo off
spool mail_text.log
begin
SELECT * FROM table1;
end;
spool off;
/usr/lib/sendmail -v <mail_id> < mail_text.logOn running the shell script, I get an error -
SELECT * FROM table1;
ERROR at line 2:
ORA-06550: line 2, column 1:
PLS-00428: an INTO clause is expected in this SELECT statement
if I am to use INTO clause, how would I spool out the data?
Looking forward to your suggestions.Caitanya wrote:
Dear All,
I have a requirement to spool out the data from a table into a log file and send it as an email.
In my unix shell script, this is what I am doing:
set def off;
set echo off
spool mail_text.log
begin
SELECT * FROM table1;
end;
spool off;
/usr/lib/sendmail -v <mail_id> < mail_text.logOn running the shell script, I get an error -
SELECT * FROM table1;
ERROR at line 2:
ORA-06550: line 2, column 1:
PLS-00428: an INTO clause is expected in this SELECT statementWhen you are issuing a select statement in PL/SQL (if you use the sql inside Begin and end), you need to put "into" some variable.
Try this
set def off;
set echo off
spool mail_text.log
SELECT * FROM table1;
spool off;
/usr/lib/sendmail -v <mail_id> < mail_text.log-Arun -
Hi Guys,
I have the following select statement…
SELECT *
FROM (SELECT '111', '222', '333' FROM dual)
Output
‘111’ ‘222’ ‘333’
1 111 222 333
But the output I was looking for was,
my_col
1 111
2 222
3 333
Can someone let me know how to achieve this?
Many Thanks…
NapsterSELECT rownum,
column_value
FROM
(SELECT '111' col1, '222' col2, '333' col3 FROM dual
) t,
TABLE(sys.odcivarchar2list(t.col1,t.col2,t.col3))Ravi Kumar -
Hi All,
Now i have created a query in which there is date of birth like(13.09.1983) Characteristic. Now i don't want to change any thing in back end but i want to display same date of birth in two different columns in 1st column only date i.e. 13 and in 2nd column month i.e. 09. How to split this record with out changing anything in back end level.
Pls help me in this.
Regards
SivaprasadHi All,
Now i have created a query in which there is date of birth like(13.09.1983) Characteristic. Now i don't want to change any thing in back end but i want to display same date of birth in two different columns in 1st column only date i.e. 13 and in 2nd column month i.e. 09. How to split this record with out changing anything in back end level.
Pls help me in this.
Regards
Hi Sivaprasad,
For this kind of requirement you need to create two different variable's with processing by customer exit.
For 1st colum - As there is no field in the backend that captures only date from complete calender date, so with wich value u want to do the comaprision of value 13 ??
For 2nd column - Similarly there is no time field in the system that capture's only month value, so again u will put restriction of this value on which info-object ??
Can u please elaborate your requirement more clearly so as to help u better.
Thanks
dipika -
How to incorporate Current Tax Period in Select Query.
i need to extract the data based on the Current Tax Period
say current tax perios is
06-04-2007 to 05-04-2008
how to incorporate this in my select query.
i need to fetch
PERNR
BEGDA
ENDDA
STAT2
FROM PA0001 INTO TABLE IT_P0001
for all entries in T_TXT_UPLOAD
WHERE PERNR = T_TXT_UPLOAD-PERNR.
In this t_txt_upload is an internal table.(input file which is taking using GUI_UPLOAD).Use this FM HR_ID_TAX_YEAR to get the starting and end date for tax year and pass the date to your SELECT command for BEGDA & ENDDA.
Regards,
Amit
Reward all helpful replies.
<b>P.S</b> Close the queries when get solved. -
Query output to have Day out of the Date
Hi,
I have developed a BEx Query with 0CALDAY in Rows and few key figures in the columns.
My BEx Query output needs to be just Day out of the Date. So if Calender Day is 26.03.2009 then in the query result I need to display '26' only.
Can you please let me know how this could be possible?
Thanks,
Amogh.Amogh,
Strange requirement!!!!!
It is feasible via Modelling i.e
1. create new Z infobject say Zday.
2. Add it ur data target. Delete the data and reload the data.
3. Map Ocalday to this object in Transforamtion and put below code
Result = SOURCE_FIELDS-CALDAY+6(2).
4. Include Zday in Bex query. -
Need help in writing a select query to pull required data from 3 tables.
Hi,
I have three tables EmpIDs,EmpRoles and LatestRoles. I need to write a select Query to get roles of all employees present in EmpIDs table by referring EmpRoles and LatestRoles.
The condition is first look into table EmpRoles and if it has more than one entry for a particular Employee ID than only need to get the Role from LatestRoles other wise consider
the role from EmpRoles .
Sample Script:
Create Table #EmpIDs
(EmplID int )
Create Table #EmpRoles
(EMPID int,Designation varchar(50))
Create Table #LatestRoles
EmpID int,
Designation varchar(50)
Insert into #EmpIDs values (1),(2),(3)
Insert into #EmpRoles values (1,'Role1'),(2,'Role1'),(2,'Role2'),(3,'Role1')
Insert into #LatestRoles values (2,'Role2')
Employee ID 2 is having two roles defined in EmpRoles so for EmpID 2 need to fetch Role from LatestRoles table and for
remaining ID's need to fetch from EmpRoles .
My Final Output of select query should be like below.
EmpID Role
1 Role1
2 Role2
3 Role1
Please help.
MohanMohan,
Can you check if this answers your requirement:
Create Table #EmpIDs
(EmplID int )
Create Table #EmpRoles
(EMPID int,Designation varchar(50))
Create Table #LatestRoles
EmpID int,
Designation varchar(50)
Insert into #EmpIDs values (1)
Insert into #EmpIDs values (2)
Insert into #EmpIDs values (3)
Insert into #EmpRoles values (1,'Role1')
Insert into #EmpRoles values (2,'Role2')
Insert into #EmpRoles values (2,'Role1')
Insert into #EmpRoles values (3,'Role1')
Insert into #LatestRoles values (2,'Role2')
--Method 1
select e.EmplID,MIN(ISNULL(l.Designation,r.Designation)) as Designation
from #empids e
left join #emproles r on e.emplID=r.EmpID
left join #latestRoles l on e.emplID=l.EmpID
group by e.EmplID
--Method 2
;with cte
as
select distinct e.EmplID,r.Designation,count(*) over(partition by e.emplID) cnt
from #empids e
left join #emproles r on e.emplID=r.EmpID
select emplID,Designation
from cte
where cnt=1
UNION ALL
select a.EmplID,l.Designation
from
(select distinct EmplID from cte where cnt>1) a
join #Latestroles l on a.EmplID=l.EmpID
order by emplID
Thanks,
Jay
<If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'> -
To lock the output of a SELECT query
Hi,
I want to lock the output of a SELECT query to some transaction.
I have wriiten it as follows , the output of the query is a single row;
SELECT empname
FROM employees
where empid = 100
FOR UPDATE;
Specifying only FOR UPDATE is proper or do i need to specify some more clause ??
Thanks.bscalzo wrote:
You can also specify the columns to lock if you like:
select x, y, z from aaa where x = 1 for update of x, y;
But the locking is still currently only done at the row level - but who knows what the future might offer. May not hurt to have the columns named for thay day when the syntax and engine sync up :)It might be worth to amend that specifying the columns is already particularly relevant if you select from multiple tables/views in order to specify which rows of which table/view to lock.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/ -
I need to add a single field from with_item table . need to write select query with reference to company code , account doc no , fiscal year
Hi Arun ,
Can you explain little bit more ??
what is account doc no?
what are the transactions should be displayed in your output??
-Rajesh N -
Fill a text box or other in a form with output of a select Query
Hi
Does anyone know if you can fill an object with an output from a select query on a form. I am trying to display a piece of data on a form , that is related to the data on the form. I do not need to edit this peice of data.
The version of PORTAL i am using does not support forms created on views.
Is this possible!!
ThanksHi
I found what I was looking for at the following forum thread.
http://forums.oracle.com/forums/message.jsp?id=471864
Thanks to Steve Yeager -
hi
sample table can be considered as scott.emp table
CREATE TABLE "EMP"
( "EMPNO" NUMBER(4,0),
"ENAME" VARCHAR2(10 BYTE),
"JOB" VARCHAR2(9 BYTE),
"MGR" NUMBER(4,0),
"HIREDATE" DATE,
"SAL" NUMBER(7,2),
"DEPTNO" NUMBER(2,0)
-- INSERTING into EMP
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7369,'SMITH','CLERK',7902,to_date('17-DEC-80','DD-MON-RR'),800,20);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7499,'ALLEN','SALESMAN',7698,to_date('20-FEB-81','DD-MON-RR'),1600,30);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7521,'WARD','SALESMAN',7698,to_date('22-FEB-81','DD-MON-RR'),1250,30);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7566,'JONES','MANAGER',7839,to_date('02-APR-81','DD-MON-RR'),2975,20);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7654,'MARTIN','SALESMAN',7698,to_date('28-SEP-81','DD-MON-RR'),1250,30);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7698,'BLAKE','MANAGER',7839,to_date('01-MAY-81','DD-MON-RR'),2850,30);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7782,'CLARK','MANAGER',7839,to_date('09-JUN-81','DD-MON-RR'),2450,10);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7788,'SCOTT','ANALYST',7566,to_date('19-APR-87','DD-MON-RR'),3000,20);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7839,'KING','PRESIDENT',null,to_date('17-NOV-81','DD-MON-RR'),5000,10);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7844,'TURNER','SALESMAN',7698,to_date('08-SEP-81','DD-MON-RR'),1500,30);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7876,'ADAMS','CLERK',7788,to_date('23-MAY-87','DD-MON-RR'),1100,20);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7900,'JAMES','CLERK',7698,to_date('03-DEC-81','DD-MON-RR'),950,30);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7902,'FORD','ANALYST',7566,to_date('03-DEC-81','DD-MON-RR'),3000,20);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7934,'MILLER','CLERK',7782,to_date('23-JAN-82','DD-MON-RR'),1300,10); In this we can see we do not have any data for the hiredate between '01-feb-81' and '20-feb-81' . But the select statement must retrun
values in between those days too with ename,job AS NULL and empno, mgr,sal as 0,depno can be 0 or any number.
i have tried something and i got the count for few columns . THe query goes something like this.
this works on a given date range . Both queries given below
select rt.business_date,
( select count(ename) from emp where trunc(hiredate) = trunc(rt.business_date) ) ename ,
( select count(empno) from emp where trunc(hiredate) = trunc(rt.business_date) ) empno ,
( select count(job) from emp where trunc(hiredate) = trunc(rt.business_date) ) job,
( select count(mgr) from emp where trunc(hiredate) = trunc(rt.business_date) ) mgr ,
( select count(deptno) from emp where trunc(hiredate) = trunc(rt.business_date) ) deptno
FROM (select ((TO_DATE(p_startdate,'mm/dd/yyyy')-1)+rnm) as business_date from (select rownum rnm from user_objects)) rt
WHERE TRUNC(rt.business_date) BETWEEN TO_DATE(p_startdate,'mm/dd/yyyy') AND TO_DATE(p_enddate,'mm/dd/yyyy')
SAMPLE OUTPUT FROM select statement has to be something like this :
empno ename job mgr HIREDATE SAL DEPTNO
7369 SMITH CLERK 7902 17-Dec-80 800 20
0 NULL NULL 0 14-Feb-81 0 0
0 NULL NULL 0 15-Feb-81 0 0
0 NULL NULL 0 16-Feb-81 0 0
0 NULL NULL 0 17-Feb-81 0 0
0 NULL NULL 0 18-Feb-81 0 0
0 NULL NULL 0 19-Feb-81 0 0
7499 ALLEN SALESMAN 7698 20-Feb-81 1600 30
7521 WARD SALESMAN 7698 22-Feb-81 1250 30
7566 JONES MANAGER 7839 2-Apr-81 2975 20
7698 BLAKE MANAGER 7839 1-May-81 2850 30
7782 CLARK MANAGER 7839 9-Jun-81 2450 10
7844 TURNER SALESMAN 7698 8-Sep-81 1500 30
7654 MARTIN SALESMAN 7698 28-Sep-81 1250 30
7839 KING PRESIDENT (null) 17-Nov-81 5000 10
7900 JAMES CLERK 7698 3-Dec-81 950 30
7902 FORD ANALYST 7566 3-Dec-81 3000 20
7934 MILLER CLERK 7782 23-Jan-82 1300 10
7788 SCOTT ANALYST 7566 19-Apr-87 3000 20
7876 ADAMS CLERK 7788 23-May-87 1100 20 Edited by: sri on Oct 19, 2011 8:36 AM
Edited by: sri on Oct 19, 2011 8:56 AMHi,
You changed your first message.
sri wrote:
hi,
i want the table data to be displayed as shown . in the quereis we are getting count of those records for that date. But i want something different . if we can see some dates there are no records but in the select statement we need to display the records in the given range of dates.
the out put can be cosnidered something like this:
THe select statment need to display hiredates data for 14 - 20 feb as shown below and this we do not have in our base table emp.
empno ename job mgr HIREDATE SAL DEPTNO
7369 SMITH CLERK 7902 17-Dec-80 800 20
0 NULL NULL 0 14-Feb-81 0 0
0 NULL NULL 0 15-Feb-81 0 0
0 NULL NULL 0 16-Feb-81 0 0
0 NULL NULL 0 17-Feb-81 0 0
0 NULL NULL 0 18-Feb-81 0 0
0 NULL NULL 0 19-Feb-81 0 0
7499 ALLEN SALESMAN 7698 20-Feb-81 1600 30
7521 WARD SALESMAN 7698 22-Feb-81 1250 30
7566 JONES MANAGER 7839 2-Apr-81 2975 20
7698 BLAKE MANAGER 7839 1-May-81 2850 30
7782 CLARK MANAGER 7839 9-Jun-81 2450 10
7844 TURNER SALESMAN 7698 8-Sep-81 1500 30
7654 MARTIN SALESMAN 7698 28-Sep-81 1250 30
7839 KING PRESIDENT (null) 17-Nov-81 5000 10
7900 JAMES CLERK 7698 3-Dec-81 950 30
7902 FORD ANALYST 7566 3-Dec-81 3000 20
7934 MILLER CLERK 7782 23-Jan-82 1300 10
7788 SCOTT ANALYST 7566 19-Apr-87 3000 20
7876 ADAMS CLERK 7788 23-May-87 1100 20
Use a FULL OUTER JOIN instead of LEFT OUTER JOIN, like this:
WITH all_dates AS
SELECT startdate + LEVEL - 1 AS dt
FROM (
SELECT TO_DATE ('02/14/1981', 'MM/DD/YYYY') AS startdate
, TO_DATE ('02/20/1981', 'MM/DD/YYYY') AS enddate
FROM dual
CONNECT BY LEVEL <= 1+ enddate - startdate
SELECT NVL (e.empno, 0) AS empno
, e.ename
, NVL (a.dt, e.hiredate) AS hiredate
-- add other columns
FROM all_dates a
FULL OUTER JOIN emp e ON a.dt = e.hiredate
ORDER BY NVL (a.dt, e.hiredate)
;
Maybe you are looking for
-
IPod nano no longer recognized USB device - after almost 2 perfect years
Okay, so I ran about 5 miles last night using my nike+ipod. The ipod worked flawlessly as usual. When I went to plug it in to my computer, instead of acting normal I got "unrecognized USB device" or something similar. iTunes didn't recognize it eithe
-
Where can I get the latest revision of Firefox for Unix?
I have Firefox in a Unix box. I need to update to the latest Firefox version for Unix. I can't find any. Is rev 3.6 available for Unix? any other?
-
Hi... I am trying to call an external function in R/3 via WebDynpro. The function uses a table with associated type W3Query. I execute the function in R/3 by adding name/value pairs to the table. In WebDynpro, I am setting the same values in table.
-
Forms 10.1.2 release date
Hi, Grant can you tell when the relase will be out and what news features are included. ThankS Jean-Yves
-
Installing photoshop elements on my new laptop
How can i transfer my photoshop elements 8 to my new laptop?