システムは、 を除いてすべての列が同じである類似の行ペアを時折生成していますstatus_code
。異なる列のペアには、NULL と数値が含まれています。
CREATE TABLE IF NOT EXISTS `delnull` (
`id` int(3) NOT NULL AUTO_INCREMENT,
`process_id` varchar(16) DEFAULT NULL,
`somedate` datetime DEFAULT NULL,
`status_desc` varchar(200) DEFAULT NULL,
`status_code` int(3) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;
--
-- Dumping data for table `delnull`
--
INSERT INTO `delnull` (`id`, `process_id`, `somedate`, `status_desc`, `status_code`) VALUES
(1, 'xyz', '2012-11-12 10:01:43', 'Completed OK', 0),
(2, 'xyz', '2012-11-12 10:01:43', 'Completed OK', NULL),
(3, 'def', '2012-11-13 10:02:11', 'Failed: broken connection', 3),
(4, 'ghi', '2012-11-09 10:02:23', 'Lost packets', 4),
(5, 'ghi', '2012-11-01 10:04:30', 'Failed: broken connection', 3),
(6, 'ghi', '2012-11-06 10:04:23', 'Lost packets', 4),
(7, 'pos', '2012-11-02 10:06:01', 'Completed OK', 0),
(8, 'pos', '2012-11-02 10:06:02', 'Completed OK', NULL);
http://sqlfiddle.com/#!2/128cc/1/0
status_code に NULL 値を含む行を識別する最良の方法は何ですか? (データセットでは、問題の行ペアは #1 と #2 であり、このペアの NULL 値であるため、#2 を特定する必要があります。