Jump to content

Recommended Posts

I am not sure how to do this.... :(

 

I have a database:

 

Customer Name

Item Number

Quantity_Purchased

Amount_Due

 

What I want to do is see one of each Item Number.  So...if more than one item is purchased by more than one person, I want to see an 'individual' list of items.  I need to do this with one query.

 

Example output:

 

Item Number

 

00022

00233

35221

 

Now 00022 has 23 purchased - so it will have at least 23 individual records...I only want to see the item in the list once.

 

I hope this makes sense...

 

Link to comment
https://forums.phpfreaks.com/topic/144514-select-one-of-each-item-query/
Share on other sites

It makes perfect sense. It is an easy SELECT query.

 

SELECT item_number, count(*) as Items_purchased FROM table GROUP BY item_number

 

Note that if you want to include the sum of quantity purchased instead of just a count for each order, you would want to use this query:

 

SELECT item_number, sum(Quantity_Purchased) as Quantity_purchased FROM table GROUP BY item_number

 

Good luck!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.