POV-Ray : Newsgroups : povray.off-topic : Another dumb SQL question Server Time
5 Sep 2024 13:10:31 EDT (-0400)
  Another dumb SQL question (Message 1 to 6 of 6)  
From: Halbert
Subject: Another dumb SQL question
Date: 22 Jul 2009 17:32:47
Message: <4a67857f@news.povray.org>
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

From: Warp
Subject: Re: Another dumb SQL question
Date: 22 Jul 2009 17:34:47
Message: <4a6785f7@news.povray.org>
Halbert <hal### [at] gmailcom> 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

From: andrel
Subject: Re: Another dumb SQL question
Date: 22 Jul 2009 17:38:59
Message: <4A6786F2.1050606@hotmail.com>
On 22-7-2009 23:34, Warp wrote:
> Halbert <hal### [at] gmailcom> 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

From: Halbert
Subject: Re: Another dumb SQL question
Date: 22 Jul 2009 17:50:20
Message: <4a67899c$1@news.povray.org>
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)

From: Darren New
Subject: Re: Another dumb SQL question
Date: 22 Jul 2009 17:54:23
Message: <4a678a8f$1@news.povray.org>
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

From: Jim Henderson
Subject: Re: Another dumb SQL question
Date: 22 Jul 2009 18:22:27
Message: <4a679123$1@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.