Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Problems
Message
From
28/10/1999 12:02:47
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
SQL Problems
Miscellaneous
Thread ID:
00283128
Message ID:
00283128
Views:
47
I'm having a problem with an SQL statement.

select course.courseid, coursematerial.textid, sum(textbook.cost);
from course left join coursematerial on course.courseid = coursematerial.courseid, textbook;
into table temptext;
group by course.courseid

The course table contains all the information of a course
The coursematerial table has courseid and the textid.
The textbook table has the costs for that textid.

I need all the course costs even if there are no textbooks for that course. So I use a left join to select all the courses from the course table and the ones that do match in the courematerial table.
So I should get a null value for the textid and the sum_cost. The problem is I get a sum for one of the courses even though it doesn't have any textbooks.

Here is the results of my SQL statement.

CourseID TextID Sum_cost
1000 cit155 12.4
2000 TR234 168.35
TTC108 NULL 168.35
TTC108D 123RT4 505.35

I don't know if that is clear enough, but I need some help.
Thanks, in advance,
Tyler
Next
Reply
Map
View

Click here to load this message in the networking platform