Need a help with SQL statement. Quickly...
Posted on 2002-05-22
I need a help with generating an SQL statement. Actually, it's a local SQL (Paradox 7.0 tables). My program is a kind of book library database manager. For the sake of simplicity let's consider it manages only these two tables:
Table "Books" has the following fields:
1) BookNo (autoinc, key)
2) Title (string, title of book)
3) Author (string, author of book)
4) Category (string, i.e. scifi, technical,...)
Table "Lendings" consists of these fields:
1) LendingNo (autoinc, key)
2) BookNo (integer, points to the key of Books table)
3) LendingDate (date, when reader borrows the specified book)
4) ReturnDate (date, when reader must return the specified book)
Books table holds information about particular books in the library. Lendings table holds information about history of all lending transactions - i.e. when reader asks to borrow some book.
What I want to do? I need to know how many lendings (records) match all of these criteria:
1) LendingDate is between :Startdate and :EndDate.
2) Book which is lent as pointed to by BookNo field of Lendings table, must be of specific :Category.
Please generate the necessary SQL statements with a *PARAMS* for me. I'm not very familiar with those SQL secrets...
Thanks in advance, Ivo.
P.S. Please be quick.