I have 2 tables. One has order elements (OE) and one has project information(PO). There are many order elements to 1 project. The way the tables are set up, the project date is is in the PO and the Currency is in the OE. I need to update the Euro Exchange rate in the OE table. I am trying to do something like this
UPDATE [OETest]
SET [Euro Exchange Rate] = {
CASE
WHEN (DATEPART(month, PO.[Project Date Time]) = January)
THEN 8.143296
WHEN (DATEPART(month, PO.[Project Date Time]) = February)
THEN 8.340111
}
FROM [POTest] PO, [OETest] OE
WHERE OE.[Currency] = 'YUAN'
But I am lost (This is one of many queries I have tried). Can anyone help me construct the necessary query and talk me through why it works?
This particular query is telling me there is Incorrect syntax near keyword CASE
To make it more clear what I am trying to accomplish: I have a column for the euro exchange rate in the OE table. I have the average monthly exchange rate that I obtained from a website (not in the table). I want to set this exchange rate column based on the month of the project and the currency. I am going to handle each currency in separate queries so the Yuan is the only currency I’m worried about for this query. The month is in the PO table. I need to use the month from the PO table in the case statement.
You only need a case statement if you need different values depending on different dates