Home » SQL & PL/SQL » SQL & PL/SQL » SQL query question (general SQL)
SQL query question [message #320352] Wed, 14 May 2008 15:32 Go to next message
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 #320353 is a reply to message #320352] Wed, 14 May 2008 15:41 Go to previous messageGo to next message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Without the description of your table we can't help you.

Regards
Michel
Re: SQL query question [message #320354 is a reply to message #320353] Wed, 14 May 2008 15:49 Go to previous messageGo to next message
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 #320366 is a reply to message #320352] Wed, 14 May 2008 18:16 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
http://www.orafaq.com/forum/t/88153/0/
Please read & FOLLOW posting guidelines as stated in URL above
Re: SQL query question [message #320371 is a reply to message #320352] Wed, 14 May 2008 19:41 Go to previous message
Kevin Meade
Messages: 2101
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
Previous Topic: How Can I pain the 'tab' in a file
Next Topic: Performance issue
Goto Forum:
  


Current Time: Fri Dec 09 21:21:55 CST 2016

Total time taken to generate the page: 0.14795 seconds