Hey all,I'm a SQL n00b in need of assistance. I'm trying to create a UID by location for a list of charges to use as an invoice number. In Excel-ese, basically i want to write =IF(C2=C1,A1,A1+1)...if that makes sense. Here's an easy sample set:create table #invoice(inv_no int,id int,location varchar(255),amount int,)insert into #invoice (id, location, amount)values (1, 'ABC',40)insert into #invoice (id, location, amount)values (2, 'ABC',30)insert into #invoice (id, location, amount)values (3, 'DEF',40)insert into #invoice (id, location, amount)values (4, 'GHI',70)
How would I write a SELECT statement so that location ABC has the same value in inv_no for both charges but it generates consecutive numerical values for DEF and GHI?Thanks in advance!EDIT: Changed question so it makes more sense.