MySQL Forums
Forum List  »  PHP

Help in Query of GROUP BY
Posted by: R G
Date: August 09, 2012 06:17AM

Hi, I am newbie, so pl help me.

I have a table of tasks of fellow persons which is updated by them with date_task, status and remarks. taskId, name_task and description are one time filled and others are updated.

The table is :-

CREATE TABLE IF NOT EXISTS `tasktry` (
`taskId` varchar(50) DEFAULT NULL,
`date_task` date NOT NULL,
`name_task` text,
`description` varchar(255) NOT NULL,
`status` text,
`remarks` mediumtext
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

and sample data is :-

INSERT INTO `tasktry` (`taskId`, `date_task`, `name_task`, `description`, `status`, `remarks`) VALUES
('neeraj-2012731163358', '2012-07-30', 'name1', 'desc1', 'Pending', 'remarks1'),
('neeraj-2012731163358', '2012-07-31', 'name1', 'desc1', 'Pending', 'remarks2'),
('rkgarg-20128117231', '2012-08-01', 'name2', 'desc2', 'Pending', 'remarks3'),
('rkgarg-20128117231', '2012-08-02', 'name2', 'desc2', 'Pending', 'remarks4'),
('neeraj-2012731163358', '2012-08-09', 'name1', 'desc1', 'Completed', 'ok');

The query is:-

SELECT taskId, name_task, description,status, MIN(date_task) as firstDate,MAX(date_task) as lastDate FROM tasktry GROUP BY taskId HAVING status='Pending'

Please help me as I don't want to see the entry of name1 in result of query as the `status` is completed.
Thanks.



Edited 1 time(s). Last edit at 08/09/2012 06:19AM by R G.

Options: ReplyQuote


Subject
Written By
Posted
Help in Query of GROUP BY
R G
August 09, 2012 06:17AM
R G
August 09, 2012 11:31AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.