بتاريخ: 1 مارس 200917 سنة comment_150229 اريد عمل كويري تطلع جدول فيه صاحب اعلى راتب في قسمهمثالاحمد 3000 المبيعاتخالد 4400 الموجودات.........وهذي محاولاتي التي لم تنجح select ename, sal, deptno from emp where exists (select deptno ,max(sal) from emp group by deptno) ; select e.ename,subquery1.deptno from emp e, (select deptno , max(sal) from emp group by deptno) subquery1 where subquery1.deptno = e.deptno; select e.ename,e.sal from emp e where exists ( select s.deptno,max(s.sal) from emp s where s.deptno=e.deptno group by deptno); تقديم بلاغ
بتاريخ: 2 مارس 200917 سنة كاتب الموضوع comment_150266 خلااااص عرفتهselect ename,deptno, sal from emp where sal in (select max(sal) from emp group by deptno)اللي ماكنت اعرفه انه ممكن نستخدم الAGG FN& GROUP BY بدون مانحط كولمن معين تقديم بلاغ
بتاريخ: 2 مارس 200917 سنة comment_150278 حلك خطأ...خود هل مثال حسب حلك:مثلاً قسم 20 فيه أعلى راتب 2000 حلك بيجبلك كل الموظفين يلي راتبون 2000 سواء كانو بقسم 20 أو غيرواهذا الحل الصحيح:طريقة أولى باستخدام الثنائيات select ename,deptno,sal from emp e where (sal,deptno) in (select max(sal),deptno from emp group by deptno) / طريقة ثانية باستخدام Correlated select ename,deptno,sal from emp e where sal in (select max(sal) from emp where deptno=e.deptno group by deptno) / تقديم بلاغ
بتاريخ: 3 مارس 200917 سنة كاتب الموضوع comment_150328 صدقت خيو .. ماكنت ملاحظ هذا الشيمع اني اتذكر جربت فكرة الاول بس ماصار .. يمكن كان عندي خطأ في الكتابةعموماجزاك الله الف خير وكثر من أمثالك تقديم بلاغ
بتاريخ: 5 مارس 200917 سنة comment_150482 SELECT * FROM EMP OUTER WHERE SAL = (SELECT MAX(SAL) FROM EMP WHERE DEPTNO = OUTER.DEPTNO) ORDER BY SAL DESC ; AND THE RESULT WILL BE LIKE THAT EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO -------- ---------- -------------- ------- --------- ----- ----- ------ ---------- 7839 KING PRESIDENT 17-NOV-81 5000 10 7788 SCOTT ANALYST 7566 19-APR-87 3000 20 7902 FORD ANALYST 7566 03-DEC-81 3000 20 7698 BLAKE MANAGER 7839 01-MAY-81 2850 3 0 تقديم بلاغ
بتاريخ: 5 مارس 200917 سنة comment_150505 طريقة ثانية باستخدام Correlatedselect ename,deptno,sal from emp e where sal in (select max(sal) from emp where deptno=e.deptno group by deptno) / هو طبعاً ما في داعي لعملية Group by ... تقديم بلاغ
بتاريخ: 7 مارس 200917 سنة comment_150626 select rownum, deptno, empcountfrom(select deptno, count(empno) empcountfrom empgroup by deptnoorder by count(empno))where rownum = 1 تقديم بلاغ
بتاريخ: 7 مارس 200917 سنة comment_150627 روعة The last one ماكنت اعرف هالطريقة وجزاك الله عنا كل خير تقديم بلاغ
بتاريخ: 8 مارس 200917 سنة comment_150650 Thank you so much 'God' You are so sweet so that I will give you another select statement select empno ,deptno , ename , sal from ( select empno ,deptno, ename, sal, dense_rank() over (partition by deptno order by sal desc)drnk from emp where sal is not null ) where drnk = 1 order by deptno, sal desc / [/b][/b] تم تعديل 8 مارس 200917 سنة بواسطة the last one تقديم بلاغ
انضم إلى المناقشة
يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.