tags:

views:

38

answers:

2

ive got a sql query which creates a table for books which stores data now how do i write an sql statement to search the database for books which the number of copies is 15 or less and make it display only the title and price.

i know it might seem really easy but ive just start learning sql

thanks

CREATE TABLE Book ( ISBN CHAR(10), title CHAR(100), author CHAR(50), copies INTEGER, price REAL )

+1  A: 

Without knowing your table layout or fields, we have to guess:

SELECT title, price
FROM Book
WHERE copies < 16

edited to reflect actual column names.

JNK
okso my one would look like this i guessSELECT title, priceFROM bookWHERE onhandcount < 16what is onhandcount is it a command
How are you tracking how many books you have in stock? I was assuming you had a column for that.
JNK
yes i got a column for that
OK I adjusted for your column names.
JNK
A: 

Assuming the following ill-advised structure. Also assume Name and price are the same for each copy of the book

Book
--------
BookId (int)
Name   (varchar)
Price  (money)

Select 
        Name,
        Price
From
        Book
Group By
        bookname,
        price
Having
        count(BookId) > 1
Conrad Frix