I have two tables items
and value
. There are many value
records in the item
table, from time to time there is a value
field in the value
record Saves item
value at that time, such as:
price table id_item timestamp value 1 2014-27-10 00:00:00 10 1 2014-27- 10 01:00:00 20 2 2014-27-10 00:00:00 10 2 2014-27-10 01:00: 00 30 ETC ...
What do I have to do Select the top 5 items
based on value
and I'm not sure for example startPrice and
endPrice
, and then add it to where
between two prices The difference is the segment, for example something like this (does not work):
SELECT `i` *, `PStart`.price` `start-up` `start-up````````````````````````````````````````````````````` and" t```_ `` _````````````````````````````````````````````````` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` ` As the name diffPrice
line it correctly with StartPrice and Andrew, but I do not tell this because name`
I'm not sure Should I go down the main route by a series of this route or subcategories? Although I can cache the query result to lighten the load, I know that the subkey can be very slow. [Edit] Thanks for the comment strawberries, I have been suggested as a SQL Bella: I would like to get this example Looking at the output: without
Item.name values Other difference Item7 70 Item6 60 items 5 50 items 4 40 items 3 30
This query For, you do not really need external integration at all, instead, find the minimum and maximum timestamp and include the price information on it:
SELECT i.start, the form of psprice In the beginning price, peprice as endprice, (pe.price-ps.price) as diffPrice item i inner join (select pid_item, min (p. Test pumps, maxim (Ptmstamp) as Group PID_ITEM) PP Joint Price PA on SS Id_item = i.id and ps.timestamp = pp.mints at PEIID value PEIIDIIT = IID and PETemstamp = PP. MXTSADRF DISC CRD5;
Comments
Post a Comment