Hi all,
I am trying to create a column that will sum two other columns based off a condition & cannot seem to get it correct. for example heres what the data looks like:
CustomerID Product Sales Sales2
1 fruit 500
2 veggi 100 200
3 veggi 50 200
4 fruit 150
the goal is create a column called sales3 that when the product = fruit it will return the Sales column and when the product = veggi it will only return sales2 column.
what is the best way to achieve this?
thank you
Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.
TRUSTED BY
ASKER