Results 1 to 3 of 3

Thread: Sql Query

  1. #1
    Join Date
    Sep 2008
    Posts
    1

    Sql Query

    hi!!!

    i hv prob in a query.......

    the tables r

    cust(cust_id(PK),fname,lname,area,phone_no)
    invoice(inv_no,mv_no(FK),cust_id(FK),issue_date,re turn_date)
    movie(mv_no(PK),title,type,star,price)

    the query is
    List the movie no. and name issue to all customers.

    tht is the query should return those mv_no which r issued to all d customers in cust table.

    can anyone help???
    thanx......

  2. #2
    Join Date
    Oct 2005
    Posts
    2,557
    As far as homework problems go, this one is very easy. I'm sure your textbook has examples of this type of query. What have you tried on your own so far?

  3. #3
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    try this

    select m.mv_no, m.title
    from movie m
    join (
    (select count(cust_id) allcustno
    from cust) c
    join
    (select mv_no, count(distinct cust_id) allcustno
    from invoice
    group by mv_no) inv
    on c.allcustno = inv.allcustno) a
    on a.mv_no=m.mv_no

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •