Link to home
Start Free TrialLog in
Avatar of MrTV
MrTVFlag for Thailand

asked on

select the frequency member ID in MYSQL

How can I select maximim top frequency duplicate MembeID
CREATE TABLE `insurance` (
  `insurprimarykey` int(11) NOT NULL AUTO_INCREMENT,
  `Insurkey` int(11) DEFAULT '0',
  `MembeID` int(11) DEFAULT NULL,
  `MemberName` varchar(250) DEFAULT NULL,
  `Amount` decimal(11,0) DEFAULT NULL,  
  PRIMARY KEY  (`insurprimarykey`),
  KEY `Membe ID` (`MembeID`)
) ENGINE=InnoDB AUTO_INCREMENT=401 DEFAULT CHARSET=tis620;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jinesh Kamdar
Jinesh Kamdar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
try this
select top 1 * from(
select MembeID ,count(*) as c from insurance
group by MembeID) as t
order by c desc

Open in new window

@HuyBD: Just for my learning, does TOP 1 work in MySQL as well ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial