Q&A for Joomla! administrators, users, developers and designers
create table #yourtable ( id bigint not null primary key, name varchar(100), salary float, gender varchar(1) ) ; INSERT INTO #yourtable(id,name,salary,gender) VALUES (1,'a',10000,'M'), (2,'b',20000,'F'), (3,'c',30000,'M'), (4,'d',40000,'F'), (5,'e',50000,'M'), (6,'f',50000,'F'), (7,'g',40000,'M'), (8,'h',40000,'F'), (9,'i',30000,'M') ; select e1.* from #yourtable e1, #yourtable e2 where -- e1.id = e2.id -- and e1.salary < e2.salary;