开发者

Expression to calculate new column value

I am connecting a clients Access database to a website but need to add a new column with data generated from 2 existing columns.

In short:

Column A contains text entries of either "4 Minute", "8 Minute" or "12 Minute".

Column B contains an amount (anything from 0 to 20)

I want t开发者_如何学Co create a new column that runs along the lines of:

If Column A = "4 Minute" Then
Column C = Column B * 4

And so on.

There are currently around 3000 records to amend before I upload and connect to the website.


Assuming text values in Column A are always [0-99] Minute then this will give you the value of the new column:

SELECT Trim(Left(ColumnA, 2))*ColumnB AS ColumnC from MyTable

If you want to store this value as a database column (though as @Remou comments ... why would you?) then:

UPDATE MyTable SET ColumnC=Trim(left(ColumnA, 2))*ColumnB
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜