i have table structure like this.. ext_no
, value
.. i want to select distinct records on condition..like when count of ext_no
is more than two and IF AND ONLY IF all that ext_no
value
is zero..
I Want Expected Result Given below...like.. how to write mysql query this this..? any help would be appreciated.. Thanks in advance..
Table Structure:
CREATE TABLE `test` (
`ext_no` int(5) default NULL,
`value` int(3) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `test`
--
INSERT INTO `test` (`ext_no`, `value`) VALUES
(12133, 0),
(12133, 0),
(12133, 0),
(22222, 0),
(44226, 0),
(44226, 0),
(44226, 1),
(44226, 2),
(99902, 1),
(99902, 2),
(99902, 3),
(11505, 0),
(11505, 0),
(11505, 0),
(11505, 0);
Expected Result:
ext_no value
12133 0
11505 0
Edit: i Tried-
select distinct ext_no, value from test where value ='0' order by ext_no DESC;