SQL & PL/SQL :: How To Display Data From Two Tables

May 13, 2013

In SQL...I want to display the manager details and the corresponding employee details and i donot want to use joins or co-related subqueries

I am trying it to use CASE or DECODE..

Here is the Query..

SELECT *
FROM (SELECT empno,
ename,
sal,
job,
CASE
WHEN empno IN (SELECT mgr FROM emp)

[code].....

The output is as follows..

7839KING5000PRESIDENT7839 KING Manager 5000 0 10
7698BLAKE2850MANAGER 7698 BLAKE 7839 2850 0 30
7782CLARK2450MANAGER 7782 CLARK 7839 2450 0 10
7566JONES2975MANAGER 7566 JONES 7839 2975 0 20
7902FORD3000ANALYST 7902 FORD 7566 3000 0 20
7788SCOTT3000ANALYST 7788 SCOTT 7566 3000 0 20

I am able to display only the Manager details or employee details and not both at the same time..

View 13 Replies


ADVERTISEMENT

Cursors - Display Data Gathered From 3 Different Tables?

Apr 30, 2010

I am stuck somewhere in my project, situation is that we are trying to display data gathered from 3 different tables, we used cursors for this, here is the cursor declaration.

DECLARE
procedure DocInfoCur(myWhere IN varchar2) IS

init_dept_id number;
init_dept_name varchar2(40);

rcvg_dept_id number;
rcvg_dept_name varchar2(40);

CURSORCUR_DOCINFO IS
SELECT DISTINCT I.CTN, I.DIARYNUMBER, I.INITIATINGDATE, T.TYPENAME, I.INITIATINGDEPT,
I.DOCUMENTSUBJECT, I.DESTINATIONDEPT
FROM DOCUMENTINFO I, DOCUMENTTYPE T, DEPARTMENT D

[code]...

This displays all the records out there.

Now, I have a search form where I need to filter the same data with different parameters, I have compiled the entered data in one string, now i need to join that string at the end of where clause of my cursor, how can I do that, i have tried concatenating both but received compile error, is there a way out in the current scenario???

View 1 Replies View Related

Display All Tables In DB (with Their Definition)?

Sep 19, 2007

I've tried using Select * from ALL_TABLES but this does not return me the column info for each table.

How do I get an output of all tables in a database along with column (e.g datatypes etc)?

I'm using TOAD v8.6.1.

View 3 Replies View Related

How To Display Unmatched Records In Two Tables

Feb 28, 2008

I want to display all records from table 1 (even the null values) that do not match records in Table 2. Below I am creating both tables and I am posting the result query I need.

------------------------------------
CREATE TABLE temp_table1
(
name VARCHAR2(12 BYTE),
last_name VARCHAR2(12 BYTE),
STATE VARCHAR2(2 BYTE),
BIRTH_DATE DATE
);

CREATE TABLE temp_table2
(
name VARCHAR2(12 BYTE),
last_name VARCHAR2(12 BYTE),
STATE VARCHAR2(2 BYTE),
BIRTH_DATE DATE
);

[code].....

The result query need to have 5 rows as shown below

NAME LAST_NAME STATE BIRTH_DATE
------------ ------------ ----- ---------------------
john smith MA 12/1/1979
null null AZ null
null null CT null
null null MA null
null null CT null

View 5 Replies View Related

SQL & PL/SQL :: Display Hierarchical Relationship Between Tables?

Mar 5, 2010

i'm trying to display the hierarchical relationship between the tables (parents-child-subchild).

[b]table structure[/b]
DEPT
|PK-DEPT_ID
|
EMP
|pk-EMP_ID
|fK emp_DEPT_fK((FK column is dept_id references dept table dept_id column))

[code]....

but by using below query i am not getting complete heirarichy.

SELECT LEVEL,
Table_Name,
Constraint_Name,
R_Constraint_Name ,
SYS_CONNECT_BY_PATH(Table_Name, '/') Path

[code]....

View 2 Replies View Related

Forms :: Display Records Of Two Tables In One Form

Mar 27, 2013

want to display records of two tables in in one form.I have 2 tables. tab1 and tab2

columns in tab1 are code, desc, part, onhand_qty AND
columns in tab2 are code, room_no, row_no, rack, shelf, qty, remarks.

Common column in both the tables is code.

i want to display all the columns of both the tables where tab1.code=tab2.code ,and tab1.onhand_qty is not equal to SUM of tab2.qty

View 1 Replies View Related

SQL & PL/SQL :: Display Ename / Contact_no / Location Joining The Two Tables?

Apr 13, 2010

i have two tables

create table tab1(
ename varchar2(10),
empid number(3) primary key);
SQL> insert into tab1 values('Ram', 101);
1 row created.
SQL> insert into tab1 values('Hari', 102);
1 row created.
SQL> insert into tab1 values('Shyam', 103);

[code]....

but i want like this

EMPID CONTACT_NO(PHONENO, MOBILENO)LOCATION
---------- -----------------------------------------
101 80123456 Banglore
101 9986234567 Banglore
102 809863728 Banglore
102 9032456578 Banglore
103 409863728 Hyderabad

[code]....

i want to display the ename,contact_no,location joining the two tables.

View 1 Replies View Related

Maintain Large Tables / Cleanup Data From Our Tables

May 18, 2011

I have to cleanup data from our tables (Production Environment) that contain millions of rows. The question is apart from the solution of the partitioned tables what alternative recommended solution suggests Oracle?

To delete these tables by using a cursor PL/SQL block or to import all the database and in the tables that we want to remove the old rows to use the QUERY option of the data pump utility.

I have used both ways and i have to admit that datapump solution is much much faster than the deletion that suffers from I/O disk.The question again is which method from these two is more reliable and less risky for the health of the database.

View 5 Replies View Related

Implementation Where Data From DB2 Tables Are Moved To Oracle Tables

Sep 3, 2012

I came across an implementation where data from DB2 tables are moved to Oracle tables, for BI solutioning, using some oracle procedures called from MS SQL DTS packages which are scheduled jobs.Just being curious, can this be done using OWB or ODI rather than the above detour. I suppose there are some changes being done in those procedures before the data is being loaded into Oracle tables, can't this be done using OWB/ODI? Can it be scheduled too as jobs using OWB/ODI?

View 1 Replies View Related

SQL & PL/SQL :: Data Display

Jul 26, 2013

I have a requirement where i need to display like

Consider EMPLOYEES table and If an employee 'A' joined in Jan month then he should come under JAN, if employee B and C joined in MARCH month than both has to come under MAR and so on..

OUTPUT:
JAN FEB MAR APR MAY JUNE JULY AUG SEP OCT NOV DEC
A B D E
C

is this possible.????

View 14 Replies View Related

Oracle Data Pump - Export Data From Schemas Or Tables

Oct 11, 2012

I need to export only the data from schemas or tables, how to do that with Oracle Data Pump? when we use schemas parameter this export all schema, not only the data right?

View 7 Replies View Related

SQL & PL/SQL :: Transpose Data And Display It

Jul 1, 2011

I have to transpose data and display it using Sql. How can I do that?

Here is how the data looks in the table now:

Deal Cashflow Date
---------------------------
0007 1228888 01/12/2011
0007 898998 02/12/2011
0007 999999 03/12/2011
0008 888888 01/12/2011
0008 777777 02/12/2011

When I transpose the data, it should look like this:

Deal 01/12/2011 02/12/2011 03/12/2011
0007 1228888 898998 999999
0008 888888 777777

Never had to do this in the past.

View 6 Replies View Related

Data Warehouse - How To Insert / Access Data In The Tables

May 30, 2011

I created a data warehouse in oracle 10g n with three Dimension and one cube after that it crates 4 tables . How to use an insert sql statement to insert data in those tables n how to access them.

View 7 Replies View Related

SQL & PL/SQL :: Display Data In Grouping Format

Oct 13, 2010

I have a query on displaying data as per my requirement. I have created a table called sales it has four columns

create table sales(country,state,district,sales);
and am inserting some same data

insert into sales('india','TN','Chennai',100);
insert into sales('india','TN','KPURAM',120);
insert into sales('india','TN','Bangalore',35);
insert into sales('india','ANDR','Guinder',100);
insert into sales('india','ANDR','Nellai',76);
insert into sales('london','city-a','xstreet',89);
insert into sales('london','city-a','binroad',100);

select * from sales;

country state district sales
india TN chennai 100
india TN KPURAM 120
india TN Bangalore 35
india ANDR Guinder 100
india ANDR Nellai 76
london city-a xstreet 89
london city-a binroad 100

the data is displayed in this format. How i am trying to display data.

View 5 Replies View Related

SQL & PL/SQL :: Page Wise Display Of Data?

Nov 11, 2010

Web page that retrives data from SQL database and display it to the user in well formatted manner. Data retrieved depend upon criterias selected by the user. But sometimes data retrieved is very large. I want to display records to the user page wise, i.e. 100 records on first page and next 100 records displayed when user clicks next button. This means only 100 records should be retrieved when user first select search criteria, next 100 records retrived when he clicks next button and so on, as to reduce data transferred from server to client. how to achieve this by using single sql query as soon as possible.

View 10 Replies View Related

SQL & PL/SQL :: Email And Display Data In Lines

Jun 6, 2012

formatting the mail message sent using utl_mail, i have created one table and it has around 17 rows inside as sample and it may increase as well, my present email format is in single line..find below the code i have written along with test case, you may substitute your emailid for test, especially my main focus is on the column mrk , where all the mrk are comming in one line but i want to be arranged in a line not more thant 10 rows, if it exceeds it should go to next line.

CREATE TABLE FAB_LOG ( MRK VARCHAR2(30))
INSERT ALL
INTO FAB_LOG VALUES ('1018017M-6001')
INTO FAB_LOG VALUES ('1018017M-6002')
INTO FAB_LOG VALUES ('1018017M-6003')
INTO FAB_LOG VALUES ('1018017M-6004')
INTO FAB_LOG VALUES ('1018017M-6005')
INTO FAB_LOG VALUES ('1018017M-6006')
[code]....

View 39 Replies View Related

SQL & PL/SQL :: How To Display Data Without Duplicate Records

Nov 16, 2011

how to display the data which is shown below without duplicate records in compid and compname and all policy_id's should be there while excuting this query iam getting this data.

select distinct comp_id as compid,
comp_disp_name as company,
plcy_id as policyid,

[Code]....

output
-----------------
compid compname policy_id policy_name

19734 Save the Children 9013 GPA
19734 Save the Children 9012 GMC
20097 JMT 9486 GTL
10890 Steelco Gujarat Ltd. 9727 CAR
17330 Golden Jubilee Hotels Limited 8915 CGL
23117 NBHC 9093 GMC
17542 Heinz India 10693 Fire
19821 KSK Fabricators 10341 D&O
3769 Jones Lang Lasalle India 9199 WC
19821 KSK Fabricators 10340 WC

View 10 Replies View Related

SQL & PL/SQL :: Display Data From Mst_user Table

Aug 9, 2011

in the below query

select
b.user_code
, b.user_name
, b.user_disabled
, b.user_email
, b.user_created_by
, b.user_created_date
, b.user_approved_by
, b.user_approved_date
, b.flag
, b.user_status
from mst_user_checker b, mst_user a
where a.user_code=b.user_code
and b.flag in ('I','P','R','F')

If the flag is 'F', then I need to display the data from the mst_user table. Where should i modify the above query ?

View 2 Replies View Related

SQL & PL/SQL :: To Display Data In Range Format

Apr 25, 2012

I have a table where multiple combination of records are store and i want to display data in range format as below, there is any way to group data as below.

create table ot_shop_Rec ( item varchar2(12), it_name varchar2(20),rev number, qty number)
drop table ot_shop_rec

insert into ot_shop_rec values ( '1018001-1001', 'COL',0,10);
insert into ot_shop_rec values ( '1018001-1002', 'COL',0,10);
insert into ot_shop_rec values ( '1018001-1001', 'GRID',0,10);
insert into ot_Shop_rec values ('1018001-1003','COL',0,10);

I WANT THE OUTPUT IN REPORT LIKE

ITEM RANGE DESC QTY REV

1018001-1001 - 1018001-1003 COL 30 0
1018001-1001 GRID 10 0

View 5 Replies View Related

PL/SQL :: How To Display Required Data From Emp Table

Dec 26, 2012

This is my first post in this portal. I want display the details of emp table.. for that I am using this SQL statement.

select * from emp where mgr=nvl(:mgr,mgr);

when I give the input as 7698 it is displaying the corresponding records... and also when I won't give any input then it isdisplaying all the records except the mgr with null values.

1)I want to display all the records when I won't give any input including nulls
2)I want to display all the records who's mgr is null

Is there any way to incorporate to include all these in a single query..

View 9 Replies View Related

Display Data From Current Date To Next 15 Days?

Jan 24, 2007

I have a Employee data as below with EID and DOB

EID DOB
----------------------
1 03/01/1950
2 14/01/1950
3 27/01/1950
4 02/02/1950
5 04/03/1950
6 12/03/1950
7 28/03/1950
8 28/02/1951
9 08/03/1951
10 28/03/1951

I need a query to display the birth date of all emp in such a way that if i run a query today the dob which lies between today & today+15 days data must be displayed.

View 8 Replies View Related

SQL & PL/SQL :: Display Data In Chinese Language In Windows 7

May 21, 2013

I want to display data in Chinese language.I have a emp table in my scott user.

View 7 Replies View Related

SQL & PL/SQL :: Procedure To Display Data From Drop Down List

Feb 6, 2012

I have to write a proc to display data based on user input for t_grp, and it should exclude grp0

So below is the proc I have written, and I want to display the report for all t_grp when user gives user_input as All or gives null. How can I acheieve this is in procedure.

table: target_data

create table target_data
(
t_mon varcahr2(6)
, t_grp varchar2(30)
, t_data varchar2(50)
)
;
INSERT INTO target_data VALUES ('Apr-11', 'grp1', 'some_data');
INSERT INTO target_data VALUES ('Apr-11', 'grp2', 'some_data');
INSERT INTO target_data VALUES ('Apr-11', 'grp4', 'some_data');
[code]......

Now the above proc is running fine, if I give the input as grp1 or any other t_grp.

View 2 Replies View Related

SQL & PL/SQL :: Display Tens Of Millions Of Data In Oracle 11g

Mar 12, 2013

i have a problem to view tens of millions of data in oracle 11g i have table Book_Issue that have tens of millions of data but when i execute query to see all the data select * from Book_Issue

it only view 5.000 data

what query should i execute to view million data in oracle 11g

View 9 Replies View Related

SQL & PL/SQL :: Display Data Based On Group And Percentage?

Feb 12, 2012

I have the following requirement, where I have to display the data based on the group and links when input is given as month. I have written the following code, which is good to display for group. But I want to display for all the groups.
CREATE TABLE target_data
(
T_LINK VARCHAR2(50)
, t_mon varchar2(6)
, t_grp varchar2(30)
, t_views NUMBER

[code]...

When I run this, I get output as

t_grp count_80 goal
grp3 1 0.1

But I want the output as

t_grp count_80 goal
grp3 1 0.1
grp2 1 0.1
grp1 ... ...
grp0 ... ...

View 16 Replies View Related

Forms :: Tool Tip Require To Display The Data

Jul 25, 2011

If it possible to display Tool Tip of a Column Require to Display the Data contain in that Column.

View 11 Replies View Related

Forms :: Manually Display Data On Form

Mar 31, 2010

How to retrieve data manually to the text fields from the EMP database.what are the main properties ?

View 5 Replies View Related

Reports & Discoverer :: How To Display Data Using User Variable

May 27, 2010

following is my query model

SELECT INV.VENDOR_ID,inv.invoice_date,inv.po_header_id,
INV.INVOICE_ID,
INV.INVOICE_NUM,

[Code]....

WHAT i have to write in select field

View 3 Replies View Related

SQL & PL/SQL :: Display Data In Required Format By Select Query?

Dec 12, 2012

i like to display a Table data like the below format,

Output:

EMPNO JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
00094 122 153 145 224 245 545 114 544 444 111 555 222
00095 233 123 145 224 205 545 114 444 444 111 555 222
00096 163 123 145 224 215 545 114 551 444 111 555 222
00097 163 0 145 224 215 545 114 551 444 111 555 222
conditions:

where condition:
where year = 2007

Table Structure:

create table HR_PAYSLIP
(
EMP_NO VARCHAR2(6) not null,
YEAR NUMBER(4) not null,
MONTH NUMBER(2) not null,
BASIC_PAY NUMBER(9,2),
)

Insert Command;

INSERT INTO PAYSLIP (EMP_NO, YEAR,MONTH,BASIC_PAY)
VALUES(00046, 2007, 1, 2314);

Pls Note: The above table data i have mentioned is an example with employee numbers and the basic_pay for all months in the particular year 2007, the employee no may be more and that must be displayed only one time like above for year 2007, and if the basic salary is zero for a month then it should be displayed as zero for a particular month

So how to write a Query for that?

View 9 Replies View Related

Forms :: Display Data Using Hierarchical Tree Up To 3 Levels?

May 17, 2010

I would like to display data using the Hierarchical tree up to 3 levels.I need to create all the nodes programatically.

Means Create the parent (Parent1) level nodes , then create the child (Child1) nodes and add them under the parent1.Similarly create child nodes (Child2) and add them under the parent (Child1).

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved