DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: sql

  1. #1
    Join Date
    Mar 2004
    Posts
    52

    sql

    I am creating a sql report in that i need to some help.

    When ever someone logs into system and upload or download a file from system ,system logs that userid ina table fileaudit and there is users table where thier usn and pwd will be stored.

    there two types of users like tier1 and tier2 both have two different tables in which they have thier details like last name , firstname and pwd and user_id will be stored in users table.


    now i would like to build a sql script where i would like to show userid and the second column will be thier full name from
    either of tables.like for example --if file1 downloaded by ron it's should display ron -- ronniejamesw

    Can some one please help me.below is the info on tables and sample data

    thanks
    *************************************************************
    fileaudit
    ----
    name null type
    -------------------
    fileauditid number
    fileauditinfo varchar2(200)

    sample data for fileaudit
    ------------------------
    234 -file23 uploaded by: ron
    456 -file96 downloaded by: mary

    users
    ----
    Name Null? Type
    ---------- -------- -------------
    USERS NOT NULL VARCHAR2(20)
    PASSWORD NOT NULL VARCHAR2(15)
    USER_ID NUMBER

    SAMPLE DATA FOR USERS TABLE
    ----------------
    RON -R2345 - 1234
    SAM -S8989 - 3444
    JON -J7777 -1234
    MARY -M112 -789


    tier1
    ------
    TIER1_ID NOT NULL NUMBER
    USERS NOT NULL VARCHAR2(20)
    FIRSTNAME NOT NULL VARCHAR2(40)
    LASTNAME NOT NULL VARCHAR2(40)
    MIDDLE_INITIAL VARCHAR2(1)

    SAMPLE DATA FOR TIER1 TABLE
    -------------------------------
    12 -JON -JONES -WELL -R
    13 -MARY-MARYIAN-JONES-W

    TIER2
    ---------
    TIER2_ID NOT NULL NUMBER
    USERS NOT NULL VARCHAR2(20)
    LASTNAME NOT NULL VARCHAR2(240)
    FIRSTNAME NOT NULL VARCHAR2(240)
    MIDDLE_INITIAL VARCHAR2(1)
    CONTACT_ID NUMBER

    SAMPLE DATA FOR TIER2 TABLE
    -----------------------------
    200-SAM-JACKSON-SAMUEL -L -98765454
    350-RON-RONNIE -JAMES-W-987654

  2. #2
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    Something like:
    Code:
    Select NVL(Tier1.lastname, Tier2.lastname), etc
    From   Users, Tier1, Tier2
    Where  Users.users = Tier1.users(+)
    and    Users.users = Tier2.users(+)

  3. #3
    Join Date
    Mar 2004
    Posts
    52
    thanks , I will try this

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width