Question Locked

Sql Query

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

i have one complecated sql quert please help me in that
the situation is like this i have one table like
bill(table name)id,date,status in that status
is always 1 or 0 and
other table like
billdetail(table name)
id,bill_id(fk of first table),itm_id(fk of third table),amount

other table is
itm(table name)
id,name

now i want to create one quert that can give me
name of item's sales in between two date which i give monthwise and whose bill status is one

so please help me in this
id

3 replies

by danlm

I doubt this is right, but I also don't think I completely understood what the billdetail table was for.

[i]select i.name
from bill b,
item i
where b.status = '1'
and b.date between TO_DATE('&fdate', 'MMDDYYYY') and TO_DATE('&tdate', 'MMDDYYYY')
and b.id = i.id[/i]

This will prompt you for the from and to dates. I prefer using full dates because you can give beginning and end of month dates this way.

dan

by dr dij

you join by specifying the key.

setup the tables (or link to a production database) in a copy of access, and visually link the tables based on which field looks up. (specify the link type)

then go 'view sql' to see the syntax. you can paste this into other query. And help you understand joins. there can be slight variations in the sql. I have two dift vsns of crystal and they produce dift syntax for same query. As does access.

This discussion is closed to new replies.