Jump to content

Having trouble with 2 SQL queries

- - - - -

  • Please log in to reply
2 replies to this topic

#1
Darkone85

Darkone85

    Learning Programmer

  • Members
  • PipPipPip
  • 30 posts
Hi, im attending this DB-course and we have been handed an assignment which is to create an EER-model and then create tables and put in data from which we got from our teacher. Then we are supposed to do a couple of assigned queries and hand in the result. This is our model: https://dl-web.dropb....png?w=df7d1bd4

And the 2 queries I cant get going is:

1. Whats the name of the seller who sold a "Ski Jumpsuit"

2. Who of our customers have made the biggest buys

I have been sitting and trying to get something going for ages now. I start to think that our model is not quite right and that I cant solve it without changing that first.

Im thinking something like:
SELECT employee.name FROM labb5.employee, labb5.order, labb5.sale, labb5.items
WHERE items.name = 'Ski Jumpsuit'
AND (items.productid = sale.items_productid)
AND (sale.order_orderid = order.orderid)
AND (order.employee_employeeid = employee.employeeid)
AND (sale.items_productid = items.produktid);

but i get an error1054, saying that sale.items_product is an unknown column in 'where' clause.

id love some input!

/Manne

#2
Darkone85

Darkone85

    Learning Programmer

  • Members
  • PipPipPip
  • 30 posts
NVM, something weird in the data we were given :)

#3
gokuajmes

gokuajmes

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 518 posts
i got ooped 403'ed with your link.anyways here is the answers if it is a single table design

select name from lab5 where itemname='Ski Jumpsuit'

and

select name from lab5 where sales =< highest >//replace it by your logic to find the highest

you got error 1054 because you are wanted a bunch of table data but forgot to specify the join




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users