mysql pivot
SELECT -- Total invoices per gender
sums.F AS "Women", sums.M AS "Men", sums.M + sums.F AS "Total"
FROM (
SELECT
SUM( IF(gender='M', invoice, 0) ) As 'M',
SUM( IF(gender='F', invoice, 0) ) As 'F'
FROM sales
) AS sums;
-- Table Sales:
CREATE TABLE sales (
gender VARCHAR(1), -- 'F' or 'M'
invoice NUMBER
);