Re: select statement error?

From: Bob Badour <bbadour_at_golden.net>
Date: Fri, 23 Jan 2004 17:08:04 -0500
Message-ID: <8dWdnUOHq9okBozdRVn-uA_at_golden.net>


"shannon" <shannon_at_nolunchmeat.com> wrote in message news:bus4tm$m1l$04$1_at_news.t-online.com...
> Hi all,
>
> i am experimenting on the online tool, SQLcourse 2 tutorial, and have
> entered the following query,
>
> SELECT lastname, item, quantity, price
> FROM items_ordered, customers
> GROUP BY lastname DESC;
>
> the answer I get looks like this,
>
> Smith Pogo stick 1 28.00
> Schultz Pogo stick 1 28.00
> Sanchez Pogo stick 1 28.00
> Sakahara Pogo stick 1 28.00
> Moore Pogo stick 1 28.00
> Mendoza Pogo stick 1 28.00
> Keller Pogo stick 1 28.00
> Jones Pogo stick 1 28.00
> Howell Pogo stick 1 28.00
> Gray Pogo stick 1 28.00
> Graham Pogo stick 1 28.00
> Giles Pogo stick 1 28.00
> Davids Pogo stick 1 28.00
> Dalton Pogo stick 1 28.00
> Cleaver Pogo stick 1 28.00
> Brown Pogo stick 1 28.00
>
> DB shows only one pogo stick sold ( to dalton)

You have a cartesian product between items_ordered and customers. You will need a where clause or join/on clause to specify how to match items_ordered with customers.

Also, you only group by one of the non-aggregate fields, which is an error even if your SQL parser fails to identify the error. Received on Fri Jan 23 2004 - 23:08:04 CET

Original text of this message