CREATE TABLE Ship (Ship_ID INT, Name TEXT, Type TEXT, Built_Year FLOAT, Class TEXT, Flag TEXT)
CREATE TABLE captain (Captain_ID INT, Name TEXT, Ship_ID INT, age TEXT, Class TEXT, Rank TEXT)

Stacked bar of class and the number of class colored by Rank, and order in ascending by the Y-axis.
SELECT Class, COUNT(Class) FROM captain GROUP BY Rank, Class ORDER BY COUNT(Class)
SELECT "Class", COUNT("Class") FROM "captain" GROUP BY "Rank", "Class" ORDER BY COUNT("Class") NULLS FIRST