hard (for me) question on database query

W

WebRaster

Hi to everyone, I need an helping hand on this question:

I'm bulding an home page of a cars seller, I need to display in this page
nine photos and descriptions taken by the database, 5 of this are fixed BUT
the other 4 elements had to be choosen in database according these select
criteria: the cheapest, the last two cars inserted in database, and the most
clicked in site. In addiction I have to avoid the accidental repetition of
elements on page, for example the ceapest car would be the last inserted in
database so could be displayed twice.

The database structure in this:
Id
product_name
description
price
number_of_click
insertion_data

My question is it's possibile create a query that can work for this problem?


THANK YOU IN ADVANCE
 
G

GreySky

Q. My question is it's possibile create a query that can
work for this problem?

A. Yes.

(Wow, "Gee thanks!" you say...)

Consider the 3 elements to your dynamic components.

1) Cheapest
2) Most clicked
3) Last 2 entered into the database

You first need to determine precedence, and then start
solving.

For example:

1) Find the cheapest. This query finds the cheapest
clunker that was dumped on the dealer before the clutch
blew.

2) Find the most clicked, that isn't the cheapest. This
query finds hot sports car with a tight paint job that
wound up being the most clicked... so long as it just so
happens not to be the cheapest. (This query also uses the
result from the first query, so the Max of the Clicks so
long as it's not the one with the slipping clutch.)

3) The last query takes the results from the first two
queries to eliminate those as candidates from the
otherwise exhaustive list of cars. Then ask for Top 2 of
this list ordered appropriately by their Entered Date and
Time (you need the time to make uniqueness; date alone
might not suffice).

I hope this helps. But in case it didn't, the simple
answer to your question is, "Yes."

David Atkins, MCP
 
W

WebRaster

Thank you for your help, but perhaps I wish in a more practical help.
If is possible for example example of code.
 
G

GreySky

Please excuse me if I'm a little frustrated at what seems
to be your unwillingness to try to write queries to solve
your problems. You didn't give me specific tables that
you had and you seemed to ask for general guidance on how
to approach the problem, and that is what I provided.

There is no cookie-cutter approach to your problem, no set-
in-stone table structure you must have in order to achieve
your goals. I am sorry, but the amount of effort you have
given to your problem does not warrant my time in
providing you a solution.

Maybe someone else would like to help.

1) Cheapest
2) Most clicked
3) Last 2 entered into the database

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top