Commonly Used Queries

download Commonly Used Queries

of 2

Transcript of Commonly Used Queries

  • 7/27/2019 Commonly Used Queries

    1/2

    1. Select All Open Service Requests

    SELECT * FROM siebel.s_srv_req sr WHERE SR_STAT_ID = 'Open';

    2. Select a Particular Service Request with a Service Request Number

    SELECT * FROM siebel.s_srv_req sr WHERE SR_NUM='1-7791439';

    3. Select a Service Request Number, Status, and Account with Service Request Numbers

    SELECT sr.SR_NUM, sr.CREATED, sr.SR_STAT_ID As Status, org.NAME AS Account FROMsiebel.s_srv_req srLEFT OUTER JOIN siebel.S_ORG_EXT org ON sr.CST_OU_ID = org.ROW_IDWHERE sr.sr_num IN ('1-26996996', '1-26996360')

    4. Select Employee Positions

    select c.fst_name, c.last_name, cp.party_id, p.namefrom siebel.s_contact c, siebel.s_party_per cp, siebel.s_postn pwhere c.row_id = cp.person_id and

    cp.party_id = p.row_id andorder by c.last_name, c.fst_name;

    5. Find all Employees with the Position of Sales

    select c.fst_name, c.last_name, u.login, p.name POSITIONfrom siebel.s_contact c, siebel.s_party_per cp, siebel.s_postn p, siebel.s_user uwhere c.row_id = cp.person_id and

    cp.party_id = p.row_id andc.row_id = u.row_id andp.name = 'SALES'

    order by c.last_name, c.fst_name

    6. Select all Employee Responsibilities

    select c.fst_name, c.last_name, r.namefrom siebel.s_contact c, siebel.s_per_resp er, siebel.s_resp rwhere c.row_id = er.per_id and

    er.resp_id = r.row_idorder by c.last_name, c.fst_name

    7. Find detailed information for a Responsibility with Responsibility Name

    SELECT * FROM siebel.s_resp r WHERE r.NAME = 'Customer Service Representative'

    8. Find and Employee list with a primary Responsibility Id

    select * from siebel.s_contact WHERE PR_RESP_ID='0-31'

    9. Select all Employees Logins, Positions, Divisions, and Organizations.

    select c.fst_name, c.last_name, u.login, p.name POSITION, d.name DIVISION, o.name ORGANIZATIONfrom siebel.s_contact c, siebel.s_party_per cp, siebel.s_postn p, siebel.s_org_ext d, siebel.s_bu o, siebel.s_user u

  • 7/27/2019 Commonly Used Queries

    2/2

    where c.row_id = cp.person_id andcp.party_id = p.row_id andp.ou_id = d.row_id andp.bu_id = o.row_id andc.row_id = u.row_id

    order by c.last_name, c.fst_name

    10. Select a service request with an Account Name (Company Name)

    SELECT sr.SR_NUM, sr.CREATED, sr.SR_STAT_ID As Status, org.NAME AS AccountFROM siebel.s_srv_req srLEFT OUTER JOIN siebel.S_ORG_EXT org ON sr.CST_OU_ID = org.ROW_ID

    SELECT sr.SR_NUM, sr.CREATED, sr.SR_STAT_ID As Status, org.NAME AS CompanyFROM siebel.s_srv_req srINNER JOIN siebel.S_ORG_EXT org ON sr.CST_OU_ID = org.ROW_ID

    11. Select a Service Request with a Service Request Number, Account, CreatedDate, Created By, and Owner

    select sr.SR_NUM, Org.NAME Account, sr.CREATED, u.login CREATED_BY, u2.login OWNERfrom siebel.s_srv_req sr

    inner join siebel.s_contact con c.row_id = sr.cst_con_id

    left outer join siebel.s_user uon sr.created_by = u.row_idleft outer join siebel.s_user u2on sr.owner_emp_id = u2.row_idleft outer join siebel.s_Org_ext Orgon sr.cst_ou_id = Org.ROW_ID

    12. Find Users who have access to a View

    SELECT ROW_ID FROM siebel.S_APP_VIEW WHERE NAME='Personal Service Request List View - Admin'

    SELECT RESP_ID FROM siebel.S_APP_VIEW_RESP WHERE VIEW_ID='1-11SQ5';

    select c.ROW_ID, c.fst_name, c.last_name, r.name, er.ROW_ID, r.ROW_IDfrom siebel.s_contact c, siebel.s_per_resp er, siebel.s_resp rwhere c.row_id = er.per_id and

    er.resp_id = r.row_id and

    r.row_id = '1-11SQY'order by c.last_name, c.fst_name