Question: sorry about the code it is sloppy right now because I've been trying to fix it. Im using a function from another file to remove even numbers from my list but after I call the function the list returns empty.

```
from usefullFunctions import *
def main ():
    mylist1 = uRandomList(10,0,15)
    listLength = len(mylist1)
    print("list1 contains %s numbers " % listLength)
    print (mylist1)
    evenOut = removeEven(mylist1)
    print (mylist1)

main()

```

These are the two functions that I am calling from the other file. 

```
def removeEven(listIn):
    result = []
    i = 0 
    while i < len(listIn):
        if (i % 2 ) == 0:
            listIn.pop(i)
        else:
            i = i + 1 
    return result

```

```
def uRandomList (num, minValue, maxValue):
    result = []
    for i in range (num):
        d1 = randint(minValue, maxValue)
        if d1 not in result:
            result.append(d1)
    return result 

```

I'm just trying to get it to remove even numbers from the list so that I can print it with the even numbers removed.
Thank you for your help in advance.

Fixed function

```
def removeEven(listIn):
    i = 0 
    while i < len(listIn):
        if listIn[i] % 2  == 0:
            listIn.pop(i)
        else:
            i = i + 1 
    return 

```

Answer: 
Its either a subquery or a group by query. Cant tell without the schema. Add the table definitions to your question and it will likely be a simple answer, unless this is already enough information. 

As a completely guessed view of your data, it will be:

```
select CourseNumber,CourseName,Department,count(*) as NumberSections
from course
join section on section.courseid=course.courseid
group by CourseNumber,CourseName,Department

```

I'm really going out on a limb here though!!
Here are a couple options:

```sql
-- left join
SELECT c.course_number, c.course_name, c.department, 
  COUNT(s.section_number) AS section_count
FROM courses c
LEFT JOIN sections s ON c.course_number = s.course_number -- get section info
GROUP BY 1,2,3
;

-- sub-query
SELECT course_number, course_name, department, 
  ( SELECT COUNT(s.section_number)
    FROM sections s 
    WHERE c.course_number = s.course_number
  ) AS section_count
FROM courses c
;

```

[SQL Fiddle](http://sqlfiddle.com/#!9/2e9127/2)

The `left join` option is probably better since it's clearer to follow and may perform faster too. Try running both and see how they perform, using an `EXPLAIN` if needed.

The previous answer uses an `inner join` which would result in no rows being returned for courses with 0 sections.