الانتقال إلى المحتوى
View in the app

A better way to browse. Learn more.

مجموعة مستخدمي أوراكل العربية

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

جملة Select محيرة _ Self Join ?

Featured Replies

بتاريخ:

الأخوة والأساتذةالأفاضل

 

    بعد التحية ،

 

أرجو إفادتي بخبراتكم العظيمة في هذه الجملة

 

المحيرة!!! 

,SELECT distinct e.manager_id,m.last_name MGR,job_grades.grade_levels GRMAN,m.salary 
e.employee_id, e.last_name EMP,job_grades.grade_levels GREMP,e.salary
FROM   employees e JOIN employees m
ON    (e.manager_id = m.employee_id)
JOIN job_grades
ON e.salary
BETWEEN LOWEST_SAL AND HIGHEST_SAL


;ORDER BY e.salary DE
الدرجات الوظيفية جاءت متساوية للمديرين ومرؤسيهم !!! وهذا خطأ لم أتمكن من تداركه ؟؟؟
 
 
مرفق صورة توضيحية وفي إنتظار حلولكم الرائعة                                                                                                              
ولكم مني كل الشكر والإعزار ،
المرفق :                                                                                                                                                          post-134310-0-79661900-1427741787_thumb.png

تم تعديل بواسطة Ahmad.Hasan

بتاريخ:

هي مش محيرة ولا حاجة ان شاء الله , بس الدنيا مش واضحة طبعا , المفروض تحط جمل الـ CREATE TABLES AND INSERT STATEMENTS عشان نفهم ونجرب .

الـ LOWEST SAL AND HIGHEST SAL مش عارفين هما تبع مين ومينفعش يبقوا تبع الـ EMPLOYEES المفروض انهم يبقوا في جدول للمرتبات الي بيقول الدرجة A اقل مرتب فيها كذا واعلي مرتب كذا .

 

وانت جايب الـ SALARY AND JOB_GRADES مرتين ليه في الكويرى وهي البيانات واحدة في الجدولين ؟

بتاريخ:
  • كاتب الموضوع

الأخ الحبيب Eslam Elbeyaly

 

طيب إيه الجملة الصحيحة من وجهة نظرك ؟؟ وخصوصآ إن الجملة إللى حضرتك أما تفضلت مشكورآ وبدلتها جابت نفس الخطأ !!!  اللى أنا كنت موضحه فى رسالتي ألآ وهو

درجة المدير = درجة مرؤوسه !!!   وهذة بالفعل نتيجة غير منطقية !!!

أرجو منك إعادة النظر فى الموضوع _ لتعم الفائدة 

 

وأشكر لك إهتمامك بالنظر والرد فى موضوعى

              تمنياتي بالتوفيق ،

تم تعديل بواسطة khaled_jazz

بتاريخ:
  • كاتب الموضوع

الأخوة الزملاء 

أعيد لكم كتابة الجملة وأرجو النظر فيها بتمعن

,SELECT distinct e.manager_id,m.last_name MGR,job_grades.grade_levels GRMAN,m.salary 

m.employee_id, e.last_name EMP,job_grades.grade_levels GREMP,e.salary FROM   employees e JOIN employees m
(ON    (e.manager_id = m.employee_id
JOIN job_grades
ON e.salary
BETWEEN LOWEST_SAL AND HIGHEST_SAL
;ORDER BY  m.salary DESC
 
المرفق :  post-134310-0-71419600-1427818244_thumb.png
بتاريخ:
  • كاتب الموضوع

الأخوة الزملاء 

أعيد لكم كتابة الجملة وأرجو النظر فيها بتمعن

,SELECT distinct e.manager_id,m.last_name MGR,job_grades.grade_levels GRMAN,m.salary 

m.employee_id, e.last_name EMP,job_grades.grade_levels GREMP,e.salary FROM   employees e JOIN employees m
(ON    (e.manager_id = m.employee_id
JOIN job_grades
ON e.salary
BETWEEN LOWEST_SAL AND HIGHEST_SAL
;ORDER BY  m.salary DESC
 
المرفق :  post-134310-0-71419600-1427818244_thumb.png
بتاريخ:

الأخ الحبيب Eslam Elbeyaly

 

طيب إيه الجملة الصحيحة من وجهة نظرك ؟؟ وخصوصآ إن الجملة إللى حضرتك أما تفضلت مشكورآ وبدلتها جابت نفس الخطأ !!!  اللى أنا كنت موضحه فى رسالتي ألآ وهو

درجة المدير = درجة مرؤوسه !!!   وهذة بالفعل نتيجة غير منطقية !!!

أرجو منك إعادة النظر فى الموضوع _ لتعم الفائدة 

 

وأشكر لك إهتمامك بالنظر والرد فى موضوعى

              تمنياتي بالتوفيق ،

انا مكتبتش جمل يا باشا !!

راجع اجابتى تاني كده , عشان تسهل ع الناس الي عايزة تجاوب .

بتاريخ:
  • كاتب الموضوع

الأخ الحبيب /  Eslam Elbeyaly

 

انا مافهمتش الجزئية دى وما أعرفش اعملها لأنى لسة ما فهمتهاش وحضرتك ماكتبتش الحل إاللى أنا أفهمه لأني جديد في الموضوع  أما عن 

 

   CREATE TABLES AND INSERT STATMENT

 

ما أعرقش لسة مردودها إيه ؟ وهل إاللى إنت ذكرته ده حيخلى درجة المدير تظهر فى الجدول أعلى من درجة الموظف !!!

حصرنك ما جاوبتش عليا بجملة سلكت ولكننى بوجه عام أشكرك على الإهتمام 

بتاريخ:

يا باشا كده احنا تايهين من بعض خااااااااالص , انا قصدي اقلك حط جملة الـ create بتاعت الجداول الي انت شغال عليها , عشان انا وغيرى نعمل الجداول عندنا , وجمل الانسرت عشان احط داتا فيها في الجداول ,

عشان نعرف نجرب الجملة .

 

- كده هيبقى صعب ان حد يجاوبك , وصعب تلاقى حد يعمل الجداول عنده بنفسه ويحط فيها داتا عشان يجرب ويجبلك الحل .

بتاريخ:
  • كاتب الموضوع

الأخ الحبيب[ Eslam Elbeyaly
 
أرجوك أعذرنى أنا معتمد إن كلكوا عندكوا الإسكيما التعليمية
 
إاللى فيها الجداول دى  ,Departments Job_Grades,Emloyee


 

أناأنشأت فقط Job_Grades ودي الجملة الخاصة بالإنشاء :

 

 

-- Create table
create table JOB_GRADES
(
  grade_levels VARCHAR2(3),
  lowest_sal   NUMBER,
  highest_sal  NUMBER
)
tablespace USERS
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
    initial 64K
    minextents 1
    maxextents unlimited
  );

===============================================================================

 

-- Create table
create table EMPLOYEES
(
  employee_id    NUMBER(6) not null,
  first_name     VARCHAR2(20),
  last_name      VARCHAR2(25),
  email          VARCHAR2(25),
  phone_number   VARCHAR2(20),
  hire_date      DATE,
  job_id         VARCHAR2(10),
  salary         NUMBER(8,2),
  commission_pct NUMBER(2,2),
  manager_id     NUMBER(6),
  department_id  NUMBER(4)
)
tablespace EXAMPLE
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
    initial 64K
    minextents 1
    maxextents unlimited
  );
-- Add comments to the table 
comment on table EMPLOYEES
  is 'employees table. Contains 107 rows. References with departments,
jobs, job_history tables. Contains a self reference.';
-- Add comments to the columns 
comment on column EMPLOYEES.employee_id
  is 'Primary key of employees table.';
comment on column EMPLOYEES.first_name
  is 'First name of the employee. A not null column.';
comment on column EMPLOYEES.last_name
  is 'Last name of the employee. A not null column.';
comment on column EMPLOYEES.email
  is 'Email id of the employee';
comment on column EMPLOYEES.phone_number
  is 'Phone number of the employee; includes country code and area code';
comment on column EMPLOYEES.hire_date
  is 'Date when the employee started on this job. A not null column.';
comment on column EMPLOYEES.job_id
  is 'Current job of the employee; foreign key to job_id column of the
jobs table. A not null column.';
comment on column EMPLOYEES.salary
  is 'Monthly salary of the employee. Must be greater
than zero (enforced by constraint emp_salary_min)';
comment on column EMPLOYEES.commission_pct
  is 'Commission percentage of the employee; Only employees in sales
department elgible for commission percentage';
comment on column EMPLOYEES.manager_id
  is 'Manager id of the employee; has same domain as manager_id in
departments table. Foreign key to employee_id column of employees table.
(useful for reflexive joins and CONNECT BY query)';
comment on column EMPLOYEES.department_id
  is 'Department id where employee works; foreign key to department_id
column of the departments table';
-- Create/Recreate primary, unique and foreign key constraints 
alter table EMPLOYEES
  add constraint EMP_EMP_ID_PK primary key (EMPLOYEE_ID)
  using index 
  tablespace EXAMPLE
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 64K
    minextents 1
    maxextents unlimited
  );
alter table EMPLOYEES
  add constraint EMP_EMAIL_UK unique (EMAIL)
  using index 
  tablespace EXAMPLE
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 64K
    minextents 1
    maxextents unlimited
  );
alter table EMPLOYEES
  add constraint EMP_DEPT_FK foreign key (DEPARTMENT_ID)
  references DEPARTMENTS (DEPARTMENT_ID);
alter table EMPLOYEES
  add constraint EMP_JOB_FK foreign key (JOB_ID)
  references JOBS (JOB_ID);
alter table EMPLOYEES
  add constraint EMP_MANAGER_FK foreign key (MANAGER_ID)
  references EMPLOYEES (EMPLOYEE_ID);
-- Create/Recreate check constraints 
alter table EMPLOYEES
  add constraint EMP_EMAIL_NN
  check ("EMAIL" IS NOT NULL);
alter table EMPLOYEES
  add constraint EMP_HIRE_DATE_NN
  check ("HIRE_DATE" IS NOT NULL);
alter table EMPLOYEES
  add constraint EMP_JOB_NN
  check ("JOB_ID" IS NOT NULL);
alter table EMPLOYEES
  add constraint EMP_LAST_NAME_NN
  check ("LAST_NAME" IS NOT NULL);
alter table EMPLOYEES
  add constraint EMP_SALARY_MIN
  check (salary > 0);
-- Create/Recreate indexes 
create index EMP_DEPARTMENT_IX on EMPLOYEES (DEPARTMENT_ID)
  tablespace EXAMPLE
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 64K
    minextents 1
    maxextents unlimited
  );
create index EMP_JOB_IX on EMPLOYEES (JOB_ID)
  tablespace EXAMPLE
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 64K
    minextents 1
    maxextents unlimited
  );
create index EMP_MANAGER_IX on EMPLOYEES (MANAGER_ID)
  tablespace EXAMPLE
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 64K
    minextents 1
    maxextents unlimited
  );
create index EMP_NAME_IX on EMPLOYEES (LAST_NAME, FIRST_NAME)
  tablespace EXAMPLE
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 64K
    minextents 1
    maxextents unlimited
  );
-- Grant/Revoke object privileges 
grant select, references on EMPLOYEES to OE;

===============================================================================

 

-- Create table
create table DEPARTMENTS
(
  department_id   NUMBER(4) not null,
  department_name VARCHAR2(30),
  manager_id      NUMBER(6),
  location_id     NUMBER(4)
)
tablespace EXAMPLE
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
    initial 64K
    minextents 1
    maxextents unlimited
  );
-- Add comments to the table 
comment on table DEPARTMENTS
  is 'Departments table that shows details of departments where employees
work. Contains 27 rows; references with locations, employees, and job_history tables.';
-- Add comments to the columns 
comment on column DEPARTMENTS.department_id
  is 'Primary key column of departments table.';
comment on column DEPARTMENTS.department_name
  is 'A not null column that shows name of a department. Administration,
Marketing, Purchasing, Human Resources, Shipping, IT, Executive, Public
Relations, Sales, Finance, and Accounting. ';
comment on column DEPARTMENTS.manager_id
  is 'Manager_id of a department. Foreign key to employee_id column of employees table. The manager_id column of the employee table references this column.';
comment on column DEPARTMENTS.location_id
  is 'Location id where a department is located. Foreign key to location_id column of locations table.';
-- Create/Recreate primary, unique and foreign key constraints 
alter table DEPARTMENTS
  add constraint DEPT_ID_PK primary key (DEPARTMENT_ID)
  using index 
  tablespace EXAMPLE
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 64K
    minextents 1
    maxextents unlimited
  );
alter table DEPARTMENTS
  add constraint DEPT_LOC_FK foreign key (LOCATION_ID)
  references LOCATIONS (LOCATION_ID);
alter table DEPARTMENTS
  add constraint DEPT_MGR_FK foreign key (MANAGER_ID)
  references EMPLOYEES (EMPLOYEE_ID);
-- Create/Recreate check constraints 
alter table DEPARTMENTS
  add constraint DEPT_NAME_NN
  check ("DEPARTMENT_NAME" IS NOT NULL);
-- Create/Recreate indexes 
create index DEPT_LOCATION_IX on DEPARTMENTS (LOCATION_ID)
  tablespace EXAMPLE
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 64K
    minextents 1
    maxextents unlimited
  );
-- Grant/Revoke object privileges 
grant select on DEPARTMENTS to OE;
===============================================================================
 
أرجوك أعذر حاجة واحدة _ إني جديد_ ومتوقع أكيد ولازم يكون عندك نفس الإسكيما  
 
وأشكرك من كل قابي على سعة صدرك
 
 post-134310-0-74794700-1427901940_thumb.png
post-134310-0-53355800-1427902038_thumb.png

تم تعديل بواسطة khaled_jazz

بتاريخ:

انا عارف ان الـ hr مفيهاش الجدول ده job_grades , فقلت انت شغال علي حاجة تانية معلش ,

المهم , عشان انا علي عجالة بس , عملتهالك علي scott , طريقتين اهم , نقى الي يعجبك  , هو نفس الحوار بس اسماء الاعمدة متغيرة , بدل الاسماء بقى واشتغل

select e.mgr , e.ename mgr_name , e.sal ,s.grade ,m.empno , m.ename emp_name from emp e , emp m , salgrade s  where e.empno = m.mgr  and e.sal between s.losal and s.hisal /  

  select e.mgr , e.ename mgr_name , e.sal ,s.grade ,m.empno , m.ename emp_name from emp e join emp m  on (e.empno = m.mgr) join salgrade s  on (e.sal between s.losal and s.hisal) /

بتاريخ:
  • كاتب الموضوع

ألأخ العزيز / Eslam Elbeyaly

 

 دخلت بيوزر Scott وكتبت الجملة إللى حضرتك

 

بعتها تمام زي الفل بس لاحظت جدول sale grale

 

فى ال Scott يحتوى درجات وظيفية 1و2و3 وهكذا

 

أما جدول job_Grades كما في ال HR فيحوى درجات

 

ولكن تكست أو VarChar2  هكذا A , B , C , D ,

 

E , F

 

ثانيأ أشكرك بوجه خاص علي صبرك مع واحد لسه

 

بيحاول يتعلم لكن هل ما فيش جملة إحترافية 

 

تتنفذ في ال HR وتجيب الصورة الأولي إللى انا 

 

أرفقتها لحضرتك فى اول المشاركة ولكن بدرجات

 

وظيفية أقل من درجة المدير ( هو دة السؤال)

 

إللى انا عايزك تجاوبنى علية وإن كنت حضرتك 

 

حلتها بشكل قريب لكن مظبوط فى الدرجات , أما

 

الصورة إللى انا أرفقها خطأ 

 

وفى النهاية يكفى مرورك الطيب والعطر لإنه خلانى

 

أفتح بقية اليوزر وأتعرف على شكل الداتا على 

 

إختلافها ما بين  أل USERS

 

 

تم تعديل بواسطة khaled_jazz

بتاريخ:

يا خالد انت نفذت الجملتين مع بعض , دول جملتين , طريقتين , خد واحدة فيهم .

وعادي يا ريس لما يكون 1 و2 و3 ولا حروف , غير اسم العمود بس ,

انت ماشي كويس يا خالد من اول دروس الـ select , ولا داخل علي الـ joins علي طول ؟

بتاريخ:

الجملة اهه عشان تطمن

تم تعديل بواسطة eslam elbyaly

بتاريخ:

الجملة اهه عشان تطمن

 

  1  select e.mgr , e.ename mgr_name , e.sal ,
  2  s.grade ,
  3  m.empno , m.ename emp_name
  4  from emp e join emp m  on (e.empno = m.mgr)
  5* join salgrade s  on (e.sal between s.losal and s.hisal)
SQL> /

       MGR MGR_NAME          SAL      GRADE      EMPNO EMP_NAME
---------- ---------- ---------- ---------- ---------- ----------
           KING             5000          5       7782 CLARK
           KING             5000          5       7698 BLAKE
           KING             5000          5       7566 JONES
      7566 SCOTT            3000          4       7876 ADAMS
      7566 FORD             3000          4       7369 SMITH
      7839 JONES            2975          4       7902 FORD
      7839 JONES            2975          4       7788 SCOTT
      7839 BLAKE            2850          4       7654 MARTIN
      7839 BLAKE            2850          4       7844 TURNER
      7839 BLAKE            2850          4       7900 JAMES
      7839 BLAKE            2850          4       7521 WARD

       MGR MGR_NAME          SAL      GRADE      EMPNO EMP_NAME
---------- ---------- ---------- ---------- ---------- ----------
      7839 BLAKE            2850          4       7499 ALLEN
      7839 CLARK            2450          4       7934 MILLER

13 rows selected.

بتاريخ:
  • كاتب الموضوع

أيوة فعلا معاك حق وأنا كنت بعدل الرسالة والله 

 

أشكرك من كل قلبى على تعبك معايا وحاول تقرأ تعديل رسالتى ليك بعد ما تداركت الوقف لوحدى اما شفت السلكت الثانيه

تم تعديل بواسطة khaled_jazz

بتاريخ:
  • كاتب الموضوع

أنا جحاوبك بصراحة أنا بذاكر الماتريال بتاع ال SQL  

 

بس كل ما بتطق فى دماغى فكرة بحاول أنفذها عشان أشوف نفسبي إستفادت وألأ لأة  ولإنى مدمن آكسيس وبأعمل إللى انا عايزه فيه

 

(يعنى فى الآكسيس بعمل العملية دى ب 2 Query) وأربط بسرعة وأرن ما تأخدش فى إيديا 3 دقائق لكن الموضوع مختلف فى الأوراكل مش

 

عارف لسة أعمل برايمارى كى لل Job_Grades حاول تنصحني أشتغل إزاي ووجهنى _ أنا آسف ع الإطالة ولكن حاسس إنك عايز تساعدني

 

ودا في حد ذاته سوف تثاب عليه .

 

 

                               وأخيرآ  لك كل الحب والإعزاز لشخصك الكريم ،

 

                                                أخوك /  خالد

انضم إلى المناقشة

يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.

زائر
أضف رد على هذا الموضوع...

برجاء الإنتباه

بإستخدامك للموقع فأنت تتعهد بالموافقة على هذه البنود: سياسة الخصوصية

Account

Navigation

البحث

إعداد إشعارات المتصفح الفورية

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.