الانتقال إلى المحتوى
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.

UNION with ORDER BY

Featured Replies

بتاريخ:

السلام عليكم
أود أن أكتب جملتين للاستعلام يربط بينهم UNION مع الترتيب ORDER BY
لكنه يظهر أن هناك خطأ
مثال :
(هذا المثال غير منطقي ولكنه للتجربة فقط)

select * from tab
union
select * from tab
order by tname
/

ERROR at line 4:
ORA-00904: "TNAME": invalid identifier

شكرا جزيلا لكم

بتاريخ:

what do u mean by Tname?
table name or a column name in one of them or both?

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

the 2 query selecting from one table

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

بما أنه ما في حد جاوبني
هذا قد يحل المشكلة

ولكن أريد رأيكم .. هل هذا الحل صحيح

select * from (
select * from tab
union
select * from tab
)
order by tname

بتاريخ:

u can not make order by table name,if u want to order by the table1 first,put it in first in ur statement

بتاريخ:


your solution is correct , but hard to write .... I think the problem of your first code was as Debug_b!bo said ... you mismatch in writing your order by column soo he show this message

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

Thank u for your reply

will you please rewrite that query to be correct

Thanks

بتاريخ:

الاخت aza
ما قمتي باقتراحه صحيح حيث يستخدم ال union لدمج بين بيانات جدولين مختلفين ولكن مشتركين بنفس بيانات عمود معين ولذلك ال order by تكتب في النهاية ويجب ان تكون تحتوي لحقل مشترك
هذا ما رغبت بتوضيحه

بتاريخ:

بسم الله الرحمن الرحيم
يمكنك إستعمال الجملة بالشكل الآتي
select a,b,c
from tab1
union
select d,e,f
from tab2
order by 1
هذا سوف يرتب بالعمود الأول مثلا وهكذا
وشكرا

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

شكرا جزيلا لكم جميعا على هذا التوضيح

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

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

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

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

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

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.