0

i want to do running total but there is no unique column or id column to be used in over clause.

CREATE TABLE piv2([name] varchar(5), [no] int);

INSERT INTO piv2
    ([name], [no])
VALUES
    ('a', 1),
    ('a', 2),
    ('a', 3),
    ('a', 4),
    ('b', 1),
    ('b', 2),
    ('b', 3);

there are only 2 columns, name which has duplicate values and the no on which i want to do running total in sql server 2017 .

expected result:

a 1
a 3
a 6
a 10
b 11
b 13
b 16

Any help??

Thom A
  • 88,727
  • 11
  • 45
  • 75
Adi
  • 329
  • 1
  • 8
  • 2
    If you're using SQL Server, don't tag other RDBMS. Doing so is not going to get your post more views but less, as if we don't know what RDBMS you are using we can't help you. As for your data, what is the expected results you're after? If `OVER` isn't going to work, because there isn't a column to `PARTITION` and `ORDER` by, then you can't get the results you're after; you need the latter to be able to create a running total. – Thom A Dec 15 '19 at 19:49
  • im confused why a simple count wont do? – Doug Coats Dec 15 '19 at 19:54
  • Results in the comments don't help us help you. Edit your question. – Thom A Dec 15 '19 at 19:55

0 Answers0