الانتقال إلى المحتوى

ممكن مساعدة فى أمر select


التميمية

Recommended Posts

عندي عدة جداول مخزنة بالاوراكل في قاعدة مستقلة والمطلوب

Which manufacturer gave Rolling Thunder the largest discount on an order in 2003?

The information we need comes from Manufacturer & PurchaseOrder tables.
We need the attributes : ManufacturerID, ManufacturerName,
OrderDate, Discount

The WHERE condition is the year 2003, which means PurchaseOrder OrderDate is Between #1/1/2003# And #12/31/2003#
To find out the largest discount, you can sort Discount attribute in Descending order

أنا كتبت هذا الكود لكن للأسف فيه خطأ ونقص يظهر لي

ORA-00918: column ambiguously defined

والكود الذي كتبت

SELECT ManufacturerID, ManufacturerName,OrderDate, Discount
FROM Manufacturer INNER JOIN PurchaseOrder
ON Manufacturer.ManufacturerID = PurchaseOrder.ManufacturerID
WHERE OrderDate Between '1/1/2003' And '12/31/2003'
ORDER BY Discount DESC;

أرجو المساعدة :rolleyes:

رابط هذا التعليق
شارك

حطيت الكود كذا
SELECT Manufacturer.ManufacturerID, ManufacturerName, OrderDate, Discount
FROM Manufacturer, PurchaseOrder
WHERE Manufacturer.ManufacturerID = PurchaseOrder.ManufacturerID
AND OrderDate Between '1/1/2002' AND '31/12/2003';
ORDER BY Discount DESC;

طلع لي ORA-00911: invalid character
!!

رابط هذا التعليق
شارك

يتم وضع علامة ;
فى نهاية الامر .. وليس فى المنتصف ..

وان كنت تستعمل oracle 10 XE يمكنك عدم اضافة ال ;
فى نهاية الامر

فيما يتعلق بالعام 2003 .. ستحتاج تعديل التاريخ from 1-1-2003 وليس 1-1-2002

select manufacturer.manufacturerid , manufacturername , orderdate,discount
from purchaseorder , manufacturer
where purchaseorder.manufacturerid = manufacturer.manufacturerid
and orderdate between '01/01/2003' and '31/12/2003' 
order by discount desc

رابط هذا التعليق
شارك

ما تقصر أخي الكريم
وسؤال : هل ممكن تختلف صياغة الأكواد والنتيجة تكون واحدة ؟
أنا مبتدئة جدا فتحملني
وهذا سؤال والمطلوب منه في الأسفل
إذا مافيه ماتع تساعدني وأدعو لك في ظهر الغيب

* The information we need comes from Manufacturer & Component tables.
* We need the attributes : ComponentID, ManufacturerName,
ProductNumber, Year, Category
* We need to create a NEW Calculated Attribute to find out the value of all the bikes available in stock. Now if we want to find the money sitting on the shelf (cost of quantity on hand) we will need to mutliply EstimatedCost * QuantityOnhand. This new attribute will give us the cost of the quantity of one product, we need the SUM of this attribute
* If you are going to use an aggregate function like SUM, you need to use GroupBy. Remember that the results must be grouped by all the attributes you have chosen in the SELECT part of your statement
* To find out the most money, you sort the NEW Calculated Attribute attribute in Descending order

المطلوب هو تحديد العنصر الاكثر كلفة والموجود بالمخازن (الاكثر كلفه بمعنى الكمية المتوفرة * السعر التقريبي)

[EstimatedCost]*[QuantityOnHand]

حاصل هذه العملية ينتج عنه تكلفة القطعة الواحدة فقط ولكن اذا اضفنا اليه الدالة SUM سينتج عنه تكلفه كافة القطع

وبالطبع كما اوضحنا في حالة استخدام الدالة SUM لابد من اضافة Group by

وكذلك لابد من الربط بين الجدولين باستخدام INNER JOIN

وفي النهاية يتم فرزالبيانات على اساس هذا العمود الحسابي الجديد ORDER BY

رابط هذا التعليق
شارك

select component.componentid , manufacturername , productnumber, year , category ,  sum( estimatedcost* quantityonhand ) as SittingOnShelf
from component , manufacturer
where component.manufacturerid = manufacturer.manufacturerid 
group by component.componentid  , manufacturername , productnumber, year , category  
order by SittingOnShelf desc 

رابط هذا التعليق
شارك

اعتقد انه .. يوجد مشكلة بالبيانات بالجداول ..
هل البيانات مدخلة بطريقه صحيحه بالجداول ؟؟

ORA-01722 

ORA-01722invalid number 

Cause:The attempted conversion of a character string to a number failed because the character string was not a valid numeric literal. Only numeric fields or character fields containing numeric data may be used in arithmetic functions or expressions. Only numeric fields may be added to or subtracted from dates. 

Action:Check the character strings in the function or expression; make sure they contain only numbers, a sign, a decimal point, and the character "E" or "e", then retry the operation. 

رابط هذا التعليق
شارك

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

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

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

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   تمت استعادة المحتوى السابق الخاص بك.   مسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

جاري التحميل
×
×
  • أضف...

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

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