Here’s what the table looks like:
create table Shipping
(
ShippingId int primary key identity(1,1),
ProductId int foreign key references Product(ProductId),
LargoEnCm decimal(16,2),
AltoEnCm decimal(16,2),
AnchoEnCm decimal(16,2),
PesoKg decimal(16,2),
PesoVolumen decimal(16,2),
PesoFacturable decimal(16,2),
A decimal(16,2),
B decimal(16,2),
C decimal(16,2),
D decimal(16,2),
E decimal(16,2),
F decimal(16,2),
G decimal(16,2)
)
For example, the field PesoVolumen should be a calculated field from this:
(LargoEnCm * AltoEnCm * AnchoEnCm) / 6000
How would I declare this calculation so that everytime someone enters the data in the rows this field is automatically populated?
How about conditional statements? Does SQL support this?
For example, in PesoFacturable the value of either PesoKg or PesoVolumen would go into it, depending on which is bigger. An If statement would solve this, can I write this directly in SQL?
1 Answer