SQL Select Help

Hello EE,
i have a select result like this :

153010      11      LDS       14      803500046178      153      1      A001
153010      11      LDS       14      803500046178      153      1      A010
153010      11      LDS       14      803500046178      153      4      J03
153010      11      LDS       16      803500046185      153      3      A010
153010      11      LDS       16      803500046185      153      1      J03
153010      21      LDS       14      803500046277      153      3      A002
153010      21      LDS       14      803500046277      153      1      A010

you see that by UPC, i have multiple values (see last column)
I would like to add a column where i would see the total by UPC, a result like this:

153010      11      LDS       14      803500046178      153      1      A001    3
153010      11      LDS       14      803500046178      153      1      A010    3
153010      11      LDS       14      803500046178      153      4      J03       3
153010      11      LDS       16      803500046185      153      3      A010    2
153010      11      LDS       16      803500046185      153      1      J03        2
153010      21      LDS       14      803500046277      153      3      A002     2
153010      21      LDS       14      803500046277      153      1      A010     2

so it would be the count by UPC

how can I do this to the actual results?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim HornMicrosoft SQL Server Data DudeCommented:
>you see that by UPC
Please add the column names to your data mockup, as I don't see a 'UPC' anywhere, and it's not clear what you wish to count.
PhilippeRenaudAuthor Commented:
see picture for better explanations.

i want a column where it would say the count of upc in my table.
in my example, you see 4 rows with that upc:   803500105288

so in the new column, for each of this upc, i would see "4"

let me know if it makes more sense.
PhilippeRenaudAuthor Commented:
sorry here is the picturesql.png
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Jim HornMicrosoft SQL Server Data DudeCommented:
For starters, give this a whirl.  Change your_table to your table name, rename any obvious stuff, and this is total air code

SELECT Styple1, StyleColor, Desc, Size, yt.UPC_NO, Season, BIN_NO, yt_sum.qty_sum
FROM your_table yt
   JOIN (
      SELECT UPC_NO, SUM(Qty) as qty_sum
      FROM your_table
      GROUP BY UPC_NO) yt_sum ON yt.UPC_NO = yt_sum.UPC_NO

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jim HornMicrosoft SQL Server Data DudeCommented:
btw, please also use the image and code buttons and not the file attach buttons, as that keeps everything in one view and saves experts a lot of time clicking back and forth, which leads to faster answers. ask-question-buttons.jpg
PhilippeRenaudAuthor Commented:
i made it happen with your code, i just changed the sum(Qty) to count(UPC_No)

Jim HornMicrosoft SQL Server Data DudeCommented:
Thanks for the grade.  Good luck with your project.  -Jim
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.