In SQL Server we can create computed column. For example:
CREATE TABLE Salary
(
id INT,
hours INT,
medical INT,
stake double,
total AS (hours * stake + medical) persisted
)
How can I create column calculated on another columns in Cosmos DB?
So, while Cosmos DB use a SQL query syntax, note that it's not a relational database such as SQL Server. As such, there is no notion of columns; there are properties within documents (and these may vary from document to document.
Things like computed columns don't exist directly; this is something you'd need to implement yourself. Lots of ways to do this, but if you're looking just at options Cosmos DB provides, you may be able to accomplish what you want with a Cosmos DB pre-trigger, where you can modify a document before it's written (in your case, computing a total
property in terms of hours
, stake
, and medical
).
You can find more information on triggers here.