Y
yyjqtww
Unregistered / Unconfirmed
GUEST, unregistred user!
我用如下语句:
SELECT s.isbn, SUM(s.linqu_total) + SUM(t.linqu_total) + SUM(l.buy_total) AS totalsum
FROM ystudentlinshu AS s, yteacherlinshu AS t, ylinshoutab AS l
WHERE (s.isbn = t.isbn) AND (s.isbn = l.isbn)
GROUP BY s.isbn
ORDER BY s.isbn
只统计出三表中具有相同字段值的记录,可是我还想让三张表中不相同的记录也显示出来,即不相同的既然不统计,但也显示它,应该如何实现呢??谢谢!
如表别名s.t.l中有
s t l
isbn total isbn total isbn total
1-1 10 1-1 10 1-1 10
2-2 10 2-1 10 2-2 10
3-3 10 3-1 10 1-1 15
想得到如下结果
isbn totalsum
1-1 45
2-1 10
2-2 20
3-1 10
3-3 10
SELECT s.isbn, SUM(s.linqu_total) + SUM(t.linqu_total) + SUM(l.buy_total) AS totalsum
FROM ystudentlinshu AS s, yteacherlinshu AS t, ylinshoutab AS l
WHERE (s.isbn = t.isbn) AND (s.isbn = l.isbn)
GROUP BY s.isbn
ORDER BY s.isbn
只统计出三表中具有相同字段值的记录,可是我还想让三张表中不相同的记录也显示出来,即不相同的既然不统计,但也显示它,应该如何实现呢??谢谢!
如表别名s.t.l中有
s t l
isbn total isbn total isbn total
1-1 10 1-1 10 1-1 10
2-2 10 2-1 10 2-2 10
3-3 10 3-1 10 1-1 15
想得到如下结果
isbn totalsum
1-1 45
2-1 10
2-2 20
3-1 10
3-3 10