0

Hey I have a table in my Database like this that you see below. I want to select "DocumentNumber" where they have similar values. You see that there is three 10006513 values

  Ducumentnumber    requestType    price    quantity       sum of price  

      10006513                       1500
      10006513                       2500
      10006513                       7500

I want to select them and write e.g: quantity = 3 and I calculate sum of price of them. I want a good query in sql server 2008

  • Since you don't know how to do something very fundamental, I've heard good things about the book, Teach Yourself SQL in 10 Minutes. – Dan Bracuk Jun 18 '13 at 12:23

1 Answers1

0
select Ducumentnumber,Count(quantity) as Quatity,sum(price)
from table1
group by Ducumentnumber

SQL Fiddle

Prahalad Gaggar
  • 11,389
  • 16
  • 53
  • 71
  • Did you know that COUNT(1) adds no value at all? http://stackoverflow.com/questions/1221559/count-vs-count1/1221649#1221649 – gbn Jun 18 '13 at 12:21
  • I wrote this and I cant bring request type in my query select distinct documentnumber , sum(price)as totalPrice from sheet group by DocumentNumber order by DocumentNumber –  Jun 18 '13 at 12:38