
use tempdb
go

drop table sales

create table sales (
  salesid int identity primary key,
  qty int,
  price money,
  total as convert(decimal(10,2),(price*qty) + 
           ((price*qty)*.062)) 
)

insert sales values(12, 4.99)
insert sales values(4, 1.00)
insert sales values(14, 10.98)
insert sales values(1, 42.00)
insert sales values(123, .99)
go

select salesid, total from sales
where total > 20
go

drop index totalidx on sales

create index totalidx on sales(total)
go

-- uses the index
select salesid, convert(decimal(10,2),(price*qty) + 
           ((price*qty)*.062)) as [tot] from sales
where convert(decimal(10,2),(price*qty) + 
           ((price*qty)*.062)) > 20
go


