سؤال

أنا أعمل مع PL / SQL (Oracle). لقد كتبت استعلامات من قبل، لكنني لست متأكدا ما هو الخطأ في هذا الاستعلام.الخطأ الذي أحصل عليه هو:

[خطأ] التنفيذ (942: 41): ORA-00979: ليست مجموعة عن طريق التعبير.

النص المميز هو: أول وظيفة تقليم في بيان الحالة.أعلم أنه لا يمكنني وضع بيان الحالة هذا في جملة المجموعة لأنني تجميع هنا (باستخدام وظيفة المجموع).هل هناك شيء أنا لا أفهمه ؟؟ giveacodicetagpre.

هل كانت مفيدة؟

المحلول

Your problem is that you are trying to access a non aggragate (LOBDESC) in a grouping context. You have two options, choose the one which makes most sense:

  • Add LOBDESC to GROUP BY
  • Use an aggregate function, i.e. MAX(LOBDESC)

نصائح أخرى

With Oracle, when grouping, you can only select either:

  • Fields appearing in the GROUP BY clause
  • Aggregate functions (COUNT, SUM, etc) on other fields

Your CASE clause will have be rewritten. Probably, you will be better off by using analytic functions for your purpose:

http://psoug.org/reference/analytic_functions.html

You have to add LOBDESC to the GROUP BY columns list because you're using it in the select outside of an agregation function.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top