1
I need to perform a query in a table of sold items where there is a Tipoitem field that says if the item is Product(1) or Service(2), I would like it to bring me two SUM’s from one of the Ocisubtot field, where if it was product(1) it brings me a SUM and if it is service(2) he brings me another column with SUM for services. Would it be possible?
Example:
SELECT
SUM(Ocisubtot) AS 'Total Produto',
SUM(Ocisubtot) AS 'Total Serviço'
FROM Orvendalevel1
Tipoitem has 1 and 2 for condition.
I am using SQL Server, I do not know if you should use IF or CASE in this case and how to apply.
Pivot com case https://stackoverflow.com/questions/5846007/sql-query-to-pivot-a-column-using-case-when
– Motta