Conditional Calculation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table with 2 fields: Zipcode and Dollar. I want to create a new
field "Relativity" that equals to Dollar/Dollar(when Zipcode=44444).

how do I write it in SQL?

Select ZipCode, Dollar, Relativity as Dollar/(Dollar When Zipcode=44444)
from table1;

Thanks,
Lily
 
This is what I want to get:
Zip Dollar Relativity
44444 1000 =1000/1000=1
44433 2000 =2000/1000=2
44456 2500 =2500/1000=2.5
44457 3000 =3000/1000=3


Thanks,
Lily
 
select z1.zipcode, z1.dollar, z1.dollar / z2.dollar as Relativity from
zipcodes z1 cross join zipcodes z2 where (z2.zipcode = 44444)
order by 3
 
Back
Top