'Selecting the name of the course that the person who consumes the most beer teaches in

I have to get the name of the course that the person teaches who consumed the most beer. Following tables are given:

The UV relationship contains information about which people (teachers) teach a certain course (at a certain time): course code (KKOD), opportunity (TERM) and teaching teacher (NAME).

The relation K contains information about courses: their course code (KKOD), course name (KNAME), number of points (POINTS) and course abbreviation (NICKNAME).

The relationship PB contains information on people's total beer consumption divided into different varieties: the person's name (NAME), Systembolaget's article number (SYSNR) and the number of liters consumed (LITER).

I have done the following to get the name of the person who've consumed the most beer;

select distinct sum(liter) over (partition by name), name from pb order by 1 desc limit 1;

try to combine with this to get the course name:

select kname from k where kkod in(select kkod from uv where name in(select*, max(sumliter) from UV,(select*,sum(liter) as sumliter from pb group by name)));

But I get this error: Error: sub-select returns 8 columns - expected 1



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source