Welcome Guest ( Log In | Register )

Bump Topic Topic Closed RSS Feed

Outline · [ Standard ] · Linear+

 Database question!, I think this is a simple one.

views
     
TSfelixwhoals
post Feb 1 2006, 08:31 AM, updated 20y ago

Casual
***
Junior Member
455 posts

Joined: Oct 2005
From: Birmingham, UK


I have Books table - ISBN DECIMAL(10) NOT NULL UNIQUE,
TITLES CHAR(100) NOT NULL,
PUBLISHERS CHAR(100) NOT NULL,
PUBLICATION_DATE DECIMAL(4) NOT NULL,
GENRE CHAR(100) NOT NULL,
PRICE DECIMAL(10,2) NOT NULL

I have saleitem table - SALE_ID DECIMAL(3) NOT NULL,
ISBN DECIMAL(10) NOT NULL,
QUANTITY DECIMAL(2) NOT NULL,
HISTORY_ID DECIMAL(3) NOT NULL

I hate price history - HISTORY_ID DECIMAL(5) NOT NULL UNIQUE,
START_DATE DATE NOT NULL,
END_DATE DATE NOT NULL,
TOTAL_PRICE DECIMAL(10,2) NOT NULL

I've tried this query: Suppose to show:

Genre total price Quantity
Programming 230.00 55
Fiction 122.00 34

select sum(Quantity), sum(total_price), genre from saleitem, pricehistory,
books group by genre, books.isbn = saleitem.isbn, saleitem.history_id =
pricehistory.history_id, pricehistory.start_date between '2006-01-01' and
'2006-01-26' and pricehistory.end_date between '2006-01-02' and '2006-01-26'
order by pricehistory.start_date;

Atribute pricehistory.start_date must be GROUPed or used in an aggregate
function

What does that mean? Could some one fix it for me? I mean what should i change?
ys_2k
post Feb 1 2006, 07:50 PM

Casual
***
Junior Member
369 posts

Joined: Jan 2003
From: Shah Alam


do u think the sql statement could be

select sum(Quantity), sum(total_price), genre from saleitem, pricehistory,books where books.isbn=saleitem.isbn and saleitem.history_id=pricehistory.history_id and pricehistory.start_date between '2006-01-01' and
'2006-01-26' and pricehistory.end_date between '2006-01-02' and '2006-01-26' group by genre;

maybe it will generate error, i didnt really look how your table structure is...the explaination i wanna to say is the arragement of the condition "WHERE" and "GROUP" have to be place carefully...
TSfelixwhoals
post Feb 2 2006, 12:30 AM

Casual
***
Junior Member
455 posts

Joined: Oct 2005
From: Birmingham, UK


Oh thank!!! U REALLY helped me a lot!!! I got the answer!!!

Topic ClosedOptions
 

Change to:
| Lo-Fi Version
0.0150sec    0.46    5 queries    GZIP Disabled
Time is now: 23rd December 2025 - 07:09 AM