Notehowwerefertocolumnswithinagiventableusingthe

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: have
an
account
with
at
 least
$100
overdrawn.

 SELECT Branch, SUM(Balance) FROM Accounts GROUP BY Branch; Branch SUM(Balance) 1 City 1129 2 Suburb 180 SELECT Branch, SUM(Balance) FROM Accounts WHERE Balance < 0 GROUP BY Branch HAVING Min(Balance) < -100; [1] Branch SUM(Balance) <0 rows> (or 0-length row.names) 4
 11/15/12
 Joining
tables
 •  Suppose
we
want
the
name(s)
of
the
owner(s)
 for
every
account

 •  The
customer
name
is
in
Customers

 •  The
account
number
is
in
Registra)on

 •  For
each
account
in
Registra)on,
we
want
the
 associated
customer
names.
 •  We
need
to
joint
two
tables
to
get
this
 informa)on
 
 •  We
can
use
AS
to
rename
tables
or
 columns.

This
can
save
a
lot
of
typing.
 SELECT Name, AcctNo AS Account FROM Customers AS C, Registrati...
View Full Document

Ask a homework question - tutors are online