COUNT AND display and Column Name in ORACLE 10G

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mukesh24
    New Member
    • Feb 2012
    • 1

    COUNT AND display and Column Name in ORACLE 10G

    How to *Count the number of Dr who are visiting 'KEM" hospital in Many to Many Relationship

    I have created 3 Tables
    Doctor dno PRIMARY KEY
    Hospital dno PRIMARY KEY
    Dochos dno REFERENCES Doctor
    hno REFERENCES Hospital

    CREATE TABLE Doctor (
    dno NUMBER(7) PRIMARY KEY,
    dname VARCHAR2(33),
    city VARCHAR2(33) not null);

    INSERT INTO Doctor VALUES (&dno, &dname, &City);

    [CODEE]CREATE TABLE Hospital (
    hno NUMBER(7) PRIMARY KEY,
    hname VARCHAR2(20),
    hcity VARCHAR2(20) not null);

    INSERT INTO Hospital VALUES (&hno, &hame, &hcity);

    CREATE TABLE Dochos (
    dno NUMBER(7) REFERENCES Doctor,
    hno NUMBER(7) REFERENCES Hospital);

    INSERT INTO Dochos VALUES (&dno, &hno);


    SQL> SELECT * FROM Doctor;

    DNO DNAME CITY
    ---------- --------------------------------- ----------------------
    1 Sharma Pune
    2 Varma Pune
    3 Swami Delhi
    4 Rashmi Mumbai

    QL> SELECT * FROM Hospital;

    HNO HNAME HCITY
    --------- -------------------- --------------------
    1 Sasoon Pune
    2 Jehagir Mumbai
    3 Rakshak Clinic Delhi
    4 Budani Pune
    5 KEM Patna

    SQL> SELECT * FROM Dochos;

    DNO HNO
    ---------- ----------
    1 1
    2 2
    3 3
    4 4[/CODE]
    Last edited by mukesh24; Feb 14 '12, 02:32 PM. Reason: /Support do not delete this post - Im trying to learn SQL by myself and needs guidance/
Working...