![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Say I have two tables:
Sales:
Manufacturer Model Number sold
========= ===== ========
Ford F10 16
Ford Model T 13
Chevy Nova 2
VW Golf 3
VW Beetle 712
Stock:
Manufacturer Model Number In Stock
========= ===== ===========
Ford Fairmont 31
Porsche 911 99
Renault Le Car 1
Cadillac El Dorado 2
VW Square Back 71
I would like to combine this data with a query for results like:
Manufacturer Number Sold Number in Stock Total
========= ========= =========== ====
Ford 29 31
60
Chevy 2 0
2
etc...
This isn't the real data, of course, just a similar example. I am just a
little fuzzy on how to get this together on SQL. Anyone have any pointers?
Muchas Gracias.
--
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Halbert <hal### [at] gmail com> wrote:
> Say I have two tables:
You should *really* use a fixed-width font when writing news posts.
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
On 22-7-2009 23:34, Warp wrote:
> Halbert <hal### [at] gmail com> wrote:
>> Say I have two tables:
>
> You should *really* use a fixed-width font when writing news posts.
I was thinking of an ethanol overdose, but you may have a point.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
You're right. I hope this is better....Say I have two
tables:Sales:Manufacturer Model Number
sold========= =====
========Ford F10 16Ford
Model T 13Chevy Nova 2VW Golf
3VW Beetle 712Stock:Manufacturer Model
Number In Stock========= =====
===========Ford Fairmont 31Porsche
911 99Renault Le Car 1Cadillac El
Dorado 2VW Square Back 71I would like to combine this
data with a query for results like:Manufacturer Number Sold
Number in Stock Total=========
========= ===========
====Ford 29 31
60Chevy 2 0
2etc...This isn't the real data, of course, just a similar example. I am
just a little fuzzy on how to get this together on SQL. Anyone have any
Post a reply to this message
Attachments:
Download 'iso-8859-1' (4 KB)
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Halbert wrote:
> This isn't the real data, of course, just a similar example. I am just a
> little fuzzy on how to get this together on SQL. Anyone have any pointers?
You want to look for "outer join" and "group by". Group each of the two
tables my manufacturer to SUM() up the number sold and number in stock, then
do an outer join on the manufacturer name (replacing NULL with 0 before
display).
--
Darren New, San Diego CA, USA (PST)
"We'd like you to back-port all the changes in 2.0
back to version 1.0."
"We've done that already. We call it 2.0."
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
On Wed, 22 Jul 2009 17:51:57 -0400, Halbert wrote:
> I hope this is better...
Not really, no - and the HTML portion of the message is generally not a
lot of use. ;-)
Jim
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |