problem of the SELECT statement. How to get data in one line
SELECTRazm.datum_sklenitve,
Razm.datum_prenehanja,
Of
zket_zaposlenci zap,
zket_delovna_razmerja razm
zket_delovne_razporeditve razp,
zket_sistemizacije_dm sistdm,
OE zket_organizacijske_enote,
zket_delovna_mesta delm
WHERE
zap.iid_zaposlenca = razm.iid_zaposlenca and
Razm.iid_delovno_razmerje = razp.iid_delovno_razmerje and
sistdm.iid_sistemizacija_dm (+) = razp.iid_sistemizacija_dm and
NVL (sistdm.iid_organizacijske_enote, razp.iid_organizacijske_enote) = oe.iid_organizacijske_enote and
sistdm.iid_delovno_mesto = delm.iid_delovno_mesto and
Razm.datum_sklenitve < = to_date ("' 31,12' |: v_datum, ' dd.mm.yyyy") and
NVL (razm.datum_prenehanja, to_date ("' 31,12' |: v_datum, ' dd.mm.yyyy")) > = to_date ("' 1.01 ' |: v_datum, ' dd.mm.yyyy") and
razp.datum_nastopa_dela < = to_date ("' 31,12' |: v_datum, ' dd.mm.yyyy") and
NVL (razp.datum_prenehanja_dela, to_date ("' 31,12' |: v_datum, ' dd.mm.yyyy")) > = to_date ("' 1.01 ' |: v_datum, ' dd.mm.yyyy") and
zkep_splosno.zkep_hierarh_oe_n (nvl (sistdm.iid_organizacijske_enote, razp.iid_organizacijske_enote): v_oe, to_date (' 31,12' |: v_datum, 'dd.mm.yyyy')) = 1 and
TO_CHAR (zkep_splosno.zkep_vrni_prvi_dr (razm.iid_delovno_razmerje, to_date ("' 31,12' |: v_datum, ' dd.mm.yyyy")), 'yyyy') =: v_datum
and zap.iid_zaposlenca = 1093507
razm.datum_sklenitve DESC order
;
return train:
datum_sklenitve datum_prenehanja
1: 01.10.2010 00:00:00 | 31.12.2010 00:00:00
2: 01.10.2010 00:00:00 | 31.12.2010 00:00:00
3: 01.04.2010 00:00:00 | 31.08.2010 00:00:00
4: 01.02.2010 00:00:00 | 31.02.2010 00:00:00
How can I get in a select just this result.
1: 01.10.2010 00:00:00 | 31.08.2010 00:00:00 (A first, then the following b which is not the same as the top of B)
I try but I don't know how. If anyone knows how to do this.
Kind regards
MB
Simma says:
But the above is not documented.
Not only that, but it's chain aggregation which is not the OP requirements.
Although you could easily forgiven as the OP has not clearly stated the logic underlying the requirements.
It could be something like original packaging SQL with something like the following...
SQL> ed
Wrote file afiedt.buf
1 with t as (select date '2010-10-01' as ds, date '2010-12-31' as dp from dual union all
2 select date '2010-10-01', date '2010-12-31' from dual union all
3 select date '2010-04-01', date '2010-08-31' from dual union all
4 select date '2010-02-01', date '2010-02-28' from dual)
5 --
6 -- END OF TEST DATA
7 --
8 select max(case when rn = 1 then ds else null end) as ds
9 ,max(case when rn = 2 then dp else null end) as dp
10 from (
11 select ds, dp, row_number() over (order by ds desc nulls last) rn
12 from (
13 select case when lag(ds) over (order by ds desc) = ds and lag(dp) over (order by ds desc) = dp then null else ds end as ds
14 ,case when lag(ds) over (order by ds desc) = ds and lag(dp) over (order by ds desc) = dp then null else dp end as dp
15 from t
16 order by t.ds
17 )
18* )
SQL> /
DS DP
------------------- -------------------
01/10/2010 00:00:00 31/08/2010 00:00:00
SQL>
but who knows?
Tags: Database
Similar Questions
-
How to get data from one or several times of perticuler dates
(1) how can we get data from one or more dates perticuler.
for example. date of 01/01/2011 and time is 00:00:00 to 23:59:59
and
(2) how can we get data from one or more dates perticuler.
from date 01/01/2011 to 01/02/2011 date and time e.g. is from 00:00:00 to 23:59:59.
can we?Hello
Use a WHERE clause to include only certain lines.
For example:SELECT * FROM table_x WHERE dt BETWEEN TO_DATE ( '01/01/2011 00:00:00' , 'DD/MM/YYYY HH24:MI:SS' ) AND TO_DATE ( '01/01/2011 23:59:59' , 'DD/MM/YYYY HH24:MI:SS' ) ;
In this example, the first date (before the keyword AND) and second (after the keyword AND) lie on the same calendar day. It's just a coincidence, they can be on different dates.
The first date must not be later than the date of the second; If this is the case, you will get 0 found lines.I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using. -
Problem in the select statement on the xmltype table
Hello
I have a table xmltype with a type of object/atrribute to the CLOB data type. When I now do a query, I get the error ORA-22835 - what goes wrong? The data type of the attribute of the source and the declared variable is CLOB.
Thanks in advance.DECLARE vFoto CLOB; BEGIN SELECT SUBSTR(pe.foto_pass, 1, 100) INTO vFoto FROM fp_epass_pass_antraege pa , XMLTABLE('/PassAntrag' PASSING pa.sys_nc_rowinfo$ COLUMNS antrag XMLTYPE PATH '/PassAntrag/Antrag' , person XMLTYPE PATH '/PassAntrag/Person') paan , XMLTABLE('/' PASSING paan.antrag COLUMNS uuid VARCHAR2(38) PATH 'UUID') an , XMLTABLE('/' PASSING paan.person COLUMNS foto_pass CLOB PATH 'FotoPass') pe WHERE an.uuid = '84239536904120131828493266953553299522'; END;
Kind regards
MartinMartin1 wrote:
But now I have to decode the base64binary data.The BLOB that results already contains the decoded base64 data.
Now, given your sample, it seems the decoded content (or at least a part of it) contains data base64 again. Is this right?
-
function() nested in the select statement
Oracle 11g. Try to nest a function within the select statement. Goal: get the average customer rating for each of the qualified user.
Select user_name, f_get_avg_cust_rating() "Notation.
of u, OTHER_TABLES o TAB_USER
where u.id = o.id and another condition matched;
How Oracle would deal with the sql. Is it
(1) first of all display records based on the where clause, then call the f_get_avg_cust_rating() for each of the selected records OR
(2) for the analysis in tables, the f_get_avg_cust_rating() will be called for each record met?
Thank you
Scott
Words of Frank, I created two functions with dbms_output and used a function in where clause in select another function. See the bottom of the unit tests. Everyone says, where first clause then select...
-Where function clause
SQL > CREATE or REPLACE FUNCTION ret_empno
2 RETURN NUMBER
3 AS
4 BEGIN
5 DBMS_OUTPUT. Put_line (' where Clause Function');
6 RETURN 7839;
7 END;
8.
The function is created.
-Select the function
SQL > CREATE or REPLACE FUNCTION ret_1
2 RETURN NUMBER
3 AS
4 BEGIN
5 DBMS_OUTPUT. Put_line ('Select function');
6 RETURN 1;
7 END;
8.
The function is created.
SQL > SELECT empno, ename,ret_1
2 FROM emp
3. WHERE empno = ret_empno;
EMPNO, ENAME RET_1
---------- ---------- ----------
7839 KING 1
Where the function Clause
Select the function
-
Cross tab in the SELECT statement?
Hello
The following SQL statement:
SELECT
T.LASTFIRST, C.COURSE_NAME, CC. COURSE_NUMBER, CC. SECTION_NUMBER, CC. EXPRESSION, ST. SEX, COUNT (CC.) STUDENTID) STUDENTCOUNT
TEACHERS T
JOIN THE CC
ON CC. TEACHERID = T.DCID
JOIN THE COURSE C
ON C.COURSE_NUMBER = CC. COURSE_NUMBER
JOIN STUDENTS ST
ON CC. STUDENTID = ST.ID
WHERE CC. SCHOOLID = 100 AND TERMID > = 1900
T.LASTFIRST, C.COURSE_NAME, CC GROUP. COURSE_NUMBER, CC. SECTION_NUMBER, CC. EXPRESSION, ST. BETWEEN THE SEXES
ORDER OF T.LASTFIRST, CC. COURSE_NUMBER, CC. SECTION_NUMBER, CC. EXPRESSION, ST. BETWEEN THE SEXES
Returns the following dataset:
Abram, American history Michael SOC1000 1 a 2 F 7
Abram, American history Michael SOC1000 1 has 2 M 12
Is there a way to make the count gender for each sex, introduce yourself as a column in the SELECT statement so that there is only ONE row returned by course number with as FEMALECOUNT and MALECOUNT column headers?
I tried to use a statement select count nested inside the original SELECT statement but without success.
JeffYou should be able to use a CASE statement for this in collaboration with the County. COUNTY does not indicate that null instances no I have not specified a part to the CASE ELSE (so the default value is NULL).
COUNT(CASE ST.GENDER WHEN 'F' THEN 1 END) as Female_count, COUNT(CASE ST.GENDER WHEN 'M' THEN 1 END) as Male_count,
Note that you need to remove the Gender of your query column.
-
How to pass parameter in the function using the select statement?
Hello
I had a problem. I can't pass as parameter to the function by using the select statement. But it can pass as a parameter using the "code". How can I solve this problem?
For example,.
Select * from table (SplitFunction ('HS750020, HS750021')) < < < this work.
but
Select * from table (SplitFunction (select LOT_NO in the TRACER_SEARCH_SCHEDULE where JOB_ID = '36')) < < < do not work.
Thank you for trying to help him. Thank you.Select * from table (SplitFunction (select LOT_NO in the TRACER_SEARCH_SCHEDULE where JOB_ID = '36'))< do="" not="">
Try like this
select * from table(select splitfunction(lot_no) from tracer_search_schedule where job_id='36')
Just make sure that your subquery returns only 1 row.
-
How to use the Type of Oracle Table values in the Select statement.
Hello
I get the initial set of values in the Table of Type Records of the Oracle and want to use the list of values in the Select statement.
For example, try something like the following:
TYPE t_record () IS RENDERING
ID TABLEA.ID%type,
NO TABLEA.NO%type
);
v_record t_record;
T_table TYPE IS the v_record TABLE % TYPE;
v_table t_table;
-Code to fill the values of v_table here.
SELECT ID, NO, COLLECT in BULK IN < some other table variabes here > FROM TABLEA
WHERE ID IN (i) v_table USER.USER;
I want to know how to use the Type of Oracle Table values in the Select statement.Something like this:
create or replace type t_record as object ( id number, no number ) / CREATE or replace type t_table AS TABLE OF t_record; / set serveroutput on declare v_table t_table := t_table(); v_t1 t_table := t_table(); begin v_table.extend(1); v_table(1).ID := 1; v_table(1).No := 10; v_table.extend(1); v_table(2).ID := 2; v_table(2).ID := 20; SELEC t_record (ID,NO) BULK COLLECT INTO v_t1 from TableA FROM TABLEA WHERE ID IN (select t.ID from table(v_Table) t); for i in 1..v_t1.count loop dbms_output.put_line(v_t1(i).ID); dbms_output.put_line(v_t1(i).No); end loop; end; /
No test!
P;
Published by: bluefrog on March 5, 2010 17:08
-
Att/yahoo updated my email, which suggests to select Firefox as the browser, but how to get back the taskbar?
Hi, you are missing the taskbar Windows, which usually appears at the bottom of the screen? Firefox normally does not block the taskbar if you do not use the mode full-screen. To check if you are using full-screen, you can use the F11 key that toggles between full screen and normal mode.
Or if you meant the menu bar (File, Edit, View), you have two options:
(1) display on request: press the ALT key to press F10 to display bar temporarily
(2) time full display: you can use one of the following methods to view the list of the toolbar, and then select menu bar it:
- Right click on a place empty on the tab bar (or the button '+')
- Press the Alt key to activate the classic menu bar > view > toolbars
- in customize mode > show/hide toolbars (see: Customize Firefox commands, buttons, and toolbars)
Success?
-
My new Mac does not have the CS5 download, how to get around this problem? I have th dvd however my Mac Pro doesn't have a hard drive.
Download from products of CS5 download
-
How to use the variable instead of the table name in the select statement of procedure
I have a procedure with a select statement with dynamic from clause. How can I use instead of the name of the table variable.
create or replace procedure scc_chemical_analysis
is
v_table_name varchar2 (100);
Start
declare
cursor c1 is select * from v_table_name; -This is the variable name. How can I use it in the select statement.
.
.
.
.
end;Hello
something like that.
1 declare 2 vSQLString VARCHAR2(32000); 3 pTableName varchar2(1000):='EMP'; 4 BEGIN 5 vSQLSTRING := 6 'SELECT ''x'' FROM ' || DBMS_ASSERT.sql_object_name(pTableName) || ' WHERE rownum<=1 '; 7 EXECUTE IMMEDIATE vSQLSTRING; 8* END; SQL> / PL/SQL procedure successfully completed.
-
Pivot will not get result in the select statement
This is the version of oracle 11g R2 on windows details 7 OS
CREATE TABLE OTBOOKINGDETAILS
(EMPNO VARCHAR2 (10 BYTE),
DATE OF OTBOOKEDDATE,
NUMBER (5.0) DAY OF THE WEEK.
DAYCEILINGHRS VARCHAR2 (10 BYTE));
Here is the data
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 MARCH 2013', 1,' 09:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 APRIL 2013', 2' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 MAY 2013', 3,' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 JUNE 2013', 4' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 JULY 2013', 5,' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 AUGUST 2013', 6,' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 SEPTEMBER 2013', 7,' 00:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (102 ', 3 MARCH 2013', 1,' 09:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (102 ', 3 APRIL 2013', 2' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (102 ', 3 MAY 2013', 3,' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (102 ', 3 JUNE 2013', 4,' 02:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (102 ', 3 JULY 2013', 5,' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (102 ', 3 AUGUST 2013', 6,' 04:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (102 ', 3 SEPTEMBER 2013', 7' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 OCTOBER 2013', 1,' 00:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 NOVEMBER 2013', 2' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 DECEMBER 2013', 3,' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 13 MARCH 2013', 4,' 04:45 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 14 MARCH 2013', 5,' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 15 MARCH 2013', 6,' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 16 MARCH 2013', 7' 01:00 ');
Here, I want to Dayceiling hours below the output using pivot
EMPNO OTBOOKEDDATE DAY1_HRS DAY2_HRS DAY3_HRS DAY4_HRS DAY5_HRS DAY6_HRS DAY7_HRS
101 03/03/2013 09:00 01:00 01:00 01:00 01:00 01:00 00:00
102 03/03/2013 09:00 01:00 01:00 02:00 01:00 04:00 01:00
101 03/10/2013 00:00 01:00 01:00 04:45 01:00 01:00 01:00ChakravarthyDBA wrote:
I need to include the pivot query in the select statementCan' are you use PIVOT here since you do not know from the start what values OTBOOKEDDATE. So use:
select empno, otbookeddate - weekday + 1 otbookeddate, max( case weekday when 1 then dayceilinghrs end ) day1_hrs, max( case weekday when 2 then dayceilinghrs end ) day2_hrs, max( case weekday when 3 then dayceilinghrs end ) day3_hrs, max( case weekday when 4 then dayceilinghrs end ) day4_hrs, max( case weekday when 5 then dayceilinghrs end ) day5_hrs, max( case weekday when 6 then dayceilinghrs end ) day6_hrs, max( case weekday when 7 then dayceilinghrs end ) day7_hrs from otbookingdetails group by empno, otbookeddate - weekday + 1 order by otbookeddate, empno / EMPNO OTBOOKEDDA DAY1_HRS DAY2_HRS DAY3_HRS DAY4_HRS DAY5_HRS DAY6_HRS DAY7_HRS ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- 101 03-03-2013 09:00 01:00 01:00 01:00 01:00 01:00 00:00 102 03-03-2013 09:00 01:00 01:00 02:00 01:00 04:00 01:00 101 10-03-2013 00:00 01:00 01:00 04:45 01:00 01:00 01:00 SQL>
SY.
-
How to ask the user to type in the select statement
Hello
Can anyone tell me the syntax of the select statement where I can ask the user to enter the value.
for example, I try to use belowthing, but it displays error
Select * from emp where empname =: empname
SP2-0552: Bind "empname' undeclared variable.
2. is there a dictionary of data table to see all pl/sql procedures and corresponding code?
Thank you
SriTry:
select * from emp where empname='&empname';
L.
-
mixture of column type in the select statement
Oracle 11g r2.
tab_test (name varchar2, blob... photo)
(1) select general use *.
Stored procedure: open ref_cursor to some * of table_test...
Coast of java: call.registerOutParameter (1, OracleTypes.CURSOR); Call.Execute ();
It works very well.
(2) enter the name of the column in the select such as
Stored procedure: open ref_cursor to select name, photo table_test...
Coast of java: call.registerOutParameter (1, OracleTypes.CURSOR); Call.Execute ();
ERROR: java.sql.SQLSyntaxErrorException: ORA-00932: inconsistent data types: expected - got BLOB
My question, if I specify the column names in the select statement, including the varchar2 and blob, how can I registerOutParameter (1, OracleTypes.CURSOR);?
Thank you
Scott
PS The number of returned columns, in real case schenario, is a little, so I prefer to specify column names.
Wrong forum. This forum is for questions of sql and pl/sql.
Enter the question ANSWER and the repost in the JDBC forum
When repost you provide the necessary information to help you:
1. information on the full version for Oracle DB
2 version of the JDK
3. the name and version of the JDBC jar file
4. real code that demonstrates the problem
You should also review the info re REF CURSOR in the JDBC Developer's Guide
http://docs.Oracle.com/CD/E16655_01/Java.121/e17657/oraint.htm#i1058743
-
uniol all in the select statement
Hi I have a situation where I have to return the value based on the if statement, is it possible to put union all in the select statement
My use case is
IN the column State
If column01 > 0 to condtion 't'
IF column02 > 0 that the condition of 'Y '.
Condition IF COLUMN03 > 0 THAN 'w '.
If COLUMN04 > 0 that the condition of "Z".
Select 't'
TableName
where column01 > 0
Union of all the
Select "y".
TableName
where column02 > 0
Union of all the
Select 'W '.
TABLENAME
WHERE COLUMN03 > 0
I have what it takes to show value as it
EmpName, condition, empno
Jerry, T, 0158754585
TOM, Y, 0054789568
Am in oracle database 11 g 2
Yes you can put all THE UNION here
Select empname, 't' State, empno from tablename where column01 > 0
Union of all the
Select empname, 't' State, empno from tablename where column02 > 0
Union of all the
Select empname, condition of "W", empno FROM tablename WHERE COLUMN03 > 0
Union of all the
Select empname, condition of "Z", empno FROM tablename WHERE COLUMN04 > 0
and if you are looking for how to remove duplicates because your line might have satisfied all the conditions and my happen 4 times in your result set, you just need to give them an order and filter it.
For example, you want this
If column01 > 0 to condtion 't'
ELSE IF column02 > 0 that the condition of 'Y '.
Another condition of THAN > 0 IF COLUMN03 'w '.
otherwise if COLUMN04 > 0 that the condition of "Z".
Select empname, condition, empno, in
(
Select a.*, row_number() over (partition by empno arrested by myorder) rn
Of
(
Select empname, 't' State, empno, 1 myorder tablename where column01 > 0
Union of all the
Select empname, 't' State, empno, 2 myorder tablename where column02 > 0
Union of all the
Select empname, condition of "W", empno 3 myorder FROM tablename WHERE COLUMN03 > 0
Union of all the
Select empname, empno, condition of 'Z', 4 myorder FROM tablename WHERE COLUMN04 > 0
) a
) where rn = 1
-
validation for each 1,000 records to be inserted in the select statement
Hi, I have the following INSERTION in the SELECT statement.
The SELECT statement (who joined) data fo about 6 crores. I need to insert this data into another table.
Please suggest me the best way to do it.
I use the INSERT in the SELECT statement, but I want to use the statement commit for each 1,000 records.
How can I do this...
Thank youinsert into emp_dept_master select e.ename ,d.dname ,e.empno ,e.empno ,e.sal from emp e , dept d where e.deptno = d.deptno ------ how to use commit for every 1000 records .
Method 4 is the best
You could combine method 3 and 1 (without dynamic SQL)
Method 2 is the less optimal solution from the list.
Maybe you are looking for
-
Satellite C70 - B - Touchpad does not work
A couple of months, I bought the Toshiba Satellite C70-B-212. However, in recent weeks the Touchpad no longer works. I already reinstalled the driver, but that didn't help. What can be the problem?
-
Windows 10 MX870 install Crash
Hello everyone, I did a clean install of Windows 10 Pro (64-bit) and I have a Pixma MX 870 that I use wireless. It and its software worked perfectly in Windows 8.1 when even, I downloaded the latest driver installation and when I run it it starts and
-
Microsoft office 2007 format compatibility pack
After you have installed the Microsoft office for word excel file formats and PowerPoint compatibility pack in office xp 2002 I can't always open a file with format 2007 excel (XLSX). The operating system is windows 2000. I realize that the pack work
-
I can't get my 4110 fujitsu scanner to work on windows 7
I can't get my fujitsu scanner 4110 to run on windows 7 appears as unknown device, drivers not found I have trried on fujitsu support site, has no drivers for windows 7,
-
Creative Cloud 2015: Limited access error
Very well.Recently, I bought the Pack student creative cloud. As I am using applications adobe on labour too, I first installed the creative cloud it. When I install the cloud creative in my home PC (Windows 7), appeared the message 'could have limit