Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / General DB Topics / DB Theory / January 2004

Tip: Looking for answers? Try searching our database.

select statement error?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
shannon - 23 Jan 2004 21:50 GMT
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)

help
Bob Badour - 23 Jan 2004 22:08 GMT
> Hi all,
>
[quoted text clipped - 25 lines]
>
> 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.
shannon - 23 Jan 2004 22:28 GMT
thanks bob,

WHERE customers . customerid = items_ordered . customerid

aah the theory is starting to click in

>>Hi all,
>>
[quoted text clipped - 32 lines]
> 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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.