SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
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  
Old May 4th, 2008, 03:59 PM
greatday greatday is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 2 greatday User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 44 m 13 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old May 5th, 2008, 07:59 AM
Wolffy's Avatar
Wolffy Wolffy is offline
Slaprentice of Wolves
Click here for more information.
 
Join Date: Aug 2007
Location: Mossville, IL
Posts: 1,015 Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 2 h 3 m 50 sec
Reputation Power: 329
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.

Reply With Quote
  #3  
Old May 5th, 2008, 03:06 PM
greatday greatday is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 2 greatday User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 44 m 13 sec
Reputation Power: 0
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??

Reply With Quote
  #4  
Old May 5th, 2008, 03:16 PM
Wolffy's Avatar
Wolffy Wolffy is offline
Slaprentice of Wolves
Click here for more information.
 
Join Date: Aug 2007
Location: Mossville, IL
Posts: 1,015 Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 2 h 3 m 50 sec
Reputation Power: 329
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:
Original - SQL Code
  1. SELECT a.Col1, b.Col2, c.Col3
  2.   FROM table1 a
  3.    JOIN table2 b
  4.      ON (a.col4 = b.col4)
  5.    JOIN table3 c
  6.      ON (b.col5 = c.col5)

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.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > Query - General - Help with some queries


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway