|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Query - General - Help with some queries
hi every one
I am making a project for school its called petstore I have created all the tables and joind them (normalized) then I inserted sample data the tables are: sale saleItem animals customers animalorder breed saleanimal supplier orderitem merchandise category city I made initial quiries with SQLplus but I am trying to modify these queries to answer the following questions: 1: List the cats born in May 2:What is the total value of animals sold in December 3:How many cats were sold in October 4:What was the most expensive item sold in July 5:Which cats sold for at least 50 percent more than their cost 6:For each merchandise supplier, what is the average shipping cost? 7:List the products with a list price greater than the average list price of all products. 8:Which customer has given us the most total money for animals and merchandise? 9:Which customers who bought more than $100 in merchandise in May also spent more than $50 on merchandise in October thats all I know they are pretty much and your help will be appreciated. thanx. |
|
#2
|
||||
|
||||
|
We're not going to do your homework for you. Take a stab at the queries and post those you have problems with, and we may help point you in the right direction.
__________________
Wolffy ------------------------ Teaching people to fish. |
|
#3
|
|||
|
|||
|
thank you mr Wolffy
thanks mr Wolffy for pointing that to me Actually Iam new to this forum and I dont know the rules verey clearly but anyways here are my answers but I am still facing so errors by SQL plus like invalid identifier and non of these worked as they should:
List the cats born in May SELECT Animal_tb.Animal_id, Animal_tb.category, Animal_tb.born_date FROM Animal_tb WHERE (((Animal_tb.category)="cat") AND ((Month([born_date]))=5)); where is the error? What is the total value of animals sold in December? SELECT Animal_tb.Animal_id, Animal_tb.category, Count(Sale_tb.Sale_ID) AS CountOfSale_ID, Sale_tb.date FROM Sale_tb INNER JOIN (Animal_tb INNER JOIN SaleAnimal_tb ON Animal_tb.Animal_id = SaleAnimal_tb.Animal_ID) ON Sale_tb.Sale_ID = SaleAnimal_tb.Sale_ID GROUP BY Animal_tb.Animal_id, Animal_tb.category, SaleAnimal_tb.price, Sale_tb.date HAVING ((Month([Sale_tb].[date])=12)); How many cats were sold in October? SELECT Count(SaleAnimal_tb.Sale_ID) AS CountOfSale_ID, SaleAnimal_tb.Animal_ID, SaleAnimal_tb.price, Sale_tb.date, Animal_tb.category FROM Sale_tb INNER JOIN (Animal_tb INNER JOIN SaleAnimal_tb ON Animal_tb.Animal_id = SaleAnimal_tb.Animal_ID) ON Sale_tb.Sale_ID = SaleAnimal_tb.Sale_ID GROUP BY SaleAnimal_tb.Animal_ID, SaleAnimal_tb.price, Sale_tb.date, Animal_tb.category HAVING ((Month([Sale_tb].[date])=10) AND ((Animal_tb.category)="cat")); Which cats sold for at least 50 percent more than their cost? SELECT Animal.AnimalID, Animal.Name, Animal.Category, [SalePrice]/[Cost] AS PriceRatio FROM (Animal INNER JOIN SaleAnimal ON Animal.AnimalID = SaleAnimal. AnimalID) INNER JOIN AnimalOrderItem ON Animal.AnimalID = AnimalOrderItem.AnimalID WHERE (((Animal.Category)="Cat") AND (([SalePrice]/[Cost])>1.5)) ORDER BY [SalePrice]/[Cost] DESC and the question is why they dont work help please?? |
|
#4
|
|||||
|
|||||
|
Whoa, one at a time. Perhaps by sorting one of the queries, you'll be able to sort the rest. (Oh, as use CODE tags around your code snippets
)Also, if you post your error messages, it will help. As for your first query. SQL uses single quotes for strings, not double. I'm thinking that your second query the syntax of the inner join is wrong: Here's an example: SQL Code:
It may be easier to write it first without the aggregate function (i.e. COUNT()) and worry about the GROUP BY and HAVING after you have the basic query sorted. |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Query - General - Help with some queries |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
![]() |
|