Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 31st, 2003, 08:14 AM
tandelaf tandelaf is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 67 tandelaf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 50 m 57 sec
Reputation Power: 5
Help with query (easy for experieced) needed.

HI, all.
I am having a bad time figuring out a good query for what I want. Wich is, to obtain the JUST (one) the latest instance (from the date-type field) for each proveedor_id (provider). As a result I just need proveedor_id, orden_fecha. In plain eglish, it is the last time an order was placed to each provider.
I have already tried a reasonable amount of time .
Please help... here´s the table structure:
Code:
CREATE TABLE `ordenes` (
  `orden_id` int(3) NOT NULL auto_increment,
  `orden_nombre` varchar(25) NOT NULL default '',
  `orden_fecha` date NOT NULL default '0000-00-00',
  `orden_comentario_texto` text NOT NULL,
  `proveedor_id` int(3) NOT NULL default '0',
  `status_orden_id` int(4) default '1',
  PRIMARY KEY  (`orden_id`)
) TYPE=MyISAM AUTO_INCREMENT=6 ;

Thanks in advance.
__________________
..:: Ignorance is *really* bliss (trust me)::..

Reply With Quote
  #2  
Old October 31st, 2003, 10:25 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,773 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 14 h 30 m 5 sec
Reputation Power: 37

Reply With Quote
  #3  
Old October 31st, 2003, 03:17 PM
tandelaf tandelaf is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 67 tandelaf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 50 m 57 sec
Reputation Power: 5
Nope.
But I solved it, this will do it:
Code:
SELECT proveedor_id, MAX(orden_fecha) FROM ordenes GROUP BY proveedor_id;
Thanks anyway for your time.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Help with query (easy for experieced) needed.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway