SQL query question [message #320352] |
Wed, 14 May 2008 15:32 |
KevinC.
Messages: 2 Registered: May 2008 Location: Duke Univ, North Carolina
|
Junior Member |
|
|
Hello,
This is my first time posting. Any input will be greatly appreciated.
I am trying to write a query that will list all customers and the purchases each has made. For example, customer A could have made 5 purchasese. I would like to list all customers and their purchases from a table.
How would I write this query?
select customer, purchase
from table aaa
group by customer ?????
Thanks for your help!
KevinC.
[Updated on: Wed, 14 May 2008 15:35] Report message to a moderator
|
|
|
|
Re: SQL query question [message #320354 is a reply to message #320353] |
Wed, 14 May 2008 15:49 |
KevinC.
Messages: 2 Registered: May 2008 Location: Duke Univ, North Carolina
|
Junior Member |
|
|
sorry.
The table key is customer ID. The table contains customer and purchase information. Each customer could appear multiple times as multiple rows. Each customer row contains a purchase for that customer.
Is there a way to select only customers who have multiple purchases that are unique within the customer? Meaning each purchase is different, no same purchase for the customer.
for example:
customer123 toy
customer123 t-shirt
customer123 shoe
Is this enough inofrmation?
Thanks,
KevinC.
[Updated on: Wed, 14 May 2008 16:04] Report message to a moderator
|
|
|
|
Re: SQL query question [message #320371 is a reply to message #320352] |
Wed, 14 May 2008 19:41 |
|
Kevin Meade
Messages: 2103 Registered: December 1999 Location: Connecticut USA
|
Senior Member |
|
|
my suggestion, swing by Borders Books and buy "SQL FOR DUMMIES", or some other similar introductory book on SQL.
Twenty dollars and three hours later you will be writing plenty of SQL.
Good luck, Kevin
|
|
|