MySqlTalk.com  

Go Back   MySqlTalk.com > MySQL > General
User Name
Password
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Search this Thread
Old 12-02-2005, 08:15 AM   #1
hessodreamy
Junior Member
 
Join Date: May 2005
Posts: 9 hessodreamy is on a distinguished road
help with GROUP BY

I have a table of customer problems, and another table of cummunications relating to the problem.

I'm trying to pull out for each problem: details of the problem, the most recent comversation, and the timestamp of the oldest conversation.

I've got the latest conversation like so:
Code:
select * from tProblems p INNER JOIN ( SELECT * FROM tProblemComments order BY uts desc ) as pc ON p.poNumber = pc.poNumber WHERE open = 1 group by p.poNumber order by p.poNumber asc
Though this probably isn't the best way forward to proper solution, and I can't think how to do it.

Any ideas?

Heres the ddl:
Code:
CREATE TABLE `tproblems` ( `poNumber` bigint(20) NOT NULL default '0', `contact` varchar(100) NOT NULL default '', `phone` varchar(100) NOT NULL default '', `open` tinyint(4) default NULL, PRIMARY KEY (`poNumber`), KEY `closed` (`open`) ) CREATE TABLE `tproblemcomments` ( `uts` int(11) NOT NULL default '0', `poNumber` int(11) NOT NULL default '0', `relevance` varchar(100) NOT NULL default '', `comment` text NOT NULL, `staff` varchar(20) NOT NULL default '', KEY `uts` (`uts`), KEY `poNumber` (`poNumber`) )
hessodreamy is offline   Fork this post Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
group and aggregate garlic General 2 06-22-2005 10:34 PM
Date GROUP and ORDER krcoder SQL syntax 1 02-07-2005 04:29 PM
problem with generating rank using group by maven9999 SQL syntax 3 11-29-2004 03:17 AM
3.6 Examples of Common Queries Administrator Documentation 9 06-29-2004 09:07 AM
3.3 Creating and Using a Database Administrator Documentation 13 06-09-2004 04:56 PM



All times are GMT -4. The time now is 06:08 AM.



Powered by: vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Google
  Web http://www.mysqltalk.com
DISCLAIMERS:
1. We have no commercial interest in this site.
Banner Ads and Subscriptions will only be used to help pay for hosting and maintenance costs.
2. MySQLTalk.com is NOT affiliated with MySQL AB in any way.
3. MySQLTalk.com is NOT endorsed by MySQL AB in any way.
4. Please do not post any content that is harmful to MySQL or MySQL AB, meaning no misleading or obsolete information will be tolerated.
Well-founded constructive criticism meant to help the community is permitted.
5. This website is founded with the goal of improving the MySQL community.
We not only tolerate newbies, we encourage them.
Please do not ask newbies to "read the manual".