This is one quick way to get the newest records of a group if you are
grouping by the sku and stock.

select stock, sku, qty
from table
where concat(dt_tm,stock,sku) IN (

select concat(max(dt_tm), stock, sku)
from table
group by stock, sku
)


Regards,
Jake Johnson
[EMAIL PROTECTED]

------------------------------------------------------------------
Plutoid - http://www.plutoid.com
Shop Plutoid for the best prices on Rims and Car Audio Products

)


> Hi,
>
> I have a SQL issue I cannot figure out, perhaps somebody can help / solve / input on 
> this ...
>
> I have a table with stock-status transactions like ...
>
> 2003-06-17 06:00 stockA SKU1 QTY 98
> 2003-06-16 06:10 stockA SKU1 QTY 101
> 2003-06-15 04:59 stockA SKU1 QTY 111
>
> - the time for updating the transaction
> - each specific stock
> - each specific SKU / partnumber
> - quantity in stock at time of transaction
>
> The SQL issue - are there some way in SQL I can SELECT only latest transaction for 
> each stock/SKU no matter date of update, or do I have to read thrue all transactions 
> and select in the program ???
>
>
> Thanks and best regards
> Peter Rasmussen
> Copenhagen Denmark
>

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to