Hi,
I have a list of product orders in a table with the following structure :
OrderID
ProductID
OrderDate
OrderCost
What query would I need to get the last order for each productID ?
Cheers,
Neil
[snip]
I have a list of product orders in a table with the following structure
:
OrderID
ProductID
OrderDate
OrderCost
What query would I need to get the last order for each productID ?
[/snip]
MAX(OrderDate)
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To
SELECT ProductID, MAX(OrderDate) FROM table GROUP BY ProductID;
or if you want all the columns
SELECT * FROM table a, (SELECT ProductID, MAX(OrderDate) as MaxDate FROM
table GROUP BY ProductID) as b WHERE a.ProductID = b.ProductID AND
a.OrderDate = b.MaxDate;
Tompkins Neil wrote:
Hi,
I
Say I have the following data:
+---+
| title
|
+---+
| ...And justice
Hi Mike, all!
Mike Spreitzer schrieb:
Today I downloaded MySQL-server-community, MySQL-client-community,
MySQL-shared-community, and mysql-workbench-gpl to install on an
RHEL5/x86_64 machine. The first three installed just fine. The fourth
failed due to a large pile of missing
Robert,
The titles should be sorted as they are stored. The 12 should come
before the other titles, just as they do with other online movie databases.
See http://www.imdb.com/find?s=allq=angry
The only problem would be of course if someone searches on Twelve, it
should also return movies
Mark Goodge wrote:
This is the sort of thing that is far better handled in the
application layer, rather than the database layer. PHP, for example,
even has a built-in function which will do this:
setype($value,float);
I agree about using the application layer, but I like to use type
Hello I am a new mysql user. Can anyone tell me why this does not create a
table?
?php(the spaces before the question mark are not in the code)
$dbuser=smeduser;
$dbpassword=x;
$dbname=smed;
mysql_connect(localhost, $dbuser, $dbpassword);
mysql_select_db($dbname) or
On Tue, July 20, 2010 09:28, dennis skinner wrote:
Hello I am a new mysql user. Can anyone tell me why this does not
create a table?
?php(the spaces before the question mark are not in the
code)
$dbuser=smeduser;
$dbpassword=x;
$dbname=smed;
'unsigned' is part of your data type which must be before the 'not
null' Your closing ) needs to be at the very end. There is no reason t
have the unique id since the primary key is unique.
First you need the column name 'patid' then the data type 'INT UNSIGNED'
then the other column
On 7/20/2010 10:07 AM, Chris W wrote:
I try to avoid asking why but in this case I have to. I can't imagine
wanting to have a list of numbers displayed and not have them all
aligned right with the sane number of digits after the decimal
point. So why would you even want to do this is?
Just out of curiosity, why not do it in the application layer?
Or maybe, you can try:
SELECT BINARY 1+1.2;
= 2.2
SELECT BINARY 1+1.0;
= 2
SELECT CAST(1+1.2 AS UNSIGNED);
= 2
SELECT CAST(1+1.6 AS UNSIGNED);
= 3 (so I guess rounding happens here)
And then I guess ultimately, you could also use
12 matches
Mail list logo