I have a problem with an SQL query on Postgresql. This select clause is an example from a lecture on databases:
1 select t.CourseNr, t.StudentsPerCourse, g.StudentCount,
2 t.StudentsPerCourse/g.StudentCount as Marketshare
3 from (select CourseNr, count(*) as StudentsPerCourse
4 from taking
5 group by CourseNr) t,
6 (select count(*) as StudentCount
7 from Students) g;
The problem is the Marketshare column in line 2. Both StudentsPerCourse and StudentCount are of type integer.
When using this on my Postgresql database, the Marketshare column is evaluated as an int type, while i would need a float/numeric here. I didn't find any way to specify the data type by searching the Postgresql Documentation on SELECT clauses nor by googling. Is there a (preferably standard SQL) way to specify the column type or am I missing something here?