I am using SQL SERVER 2012
I want to make a subquery with data from the same table that has the query relating three fields, I mean, the query is
SELECT m.COMPROBANT, COUNT (m.COMPROBANT)Item_ENTRADA, m.FECHA_TRS,m.COD_PROVEE,m.COD_AREA,
SUM(m.ENTRADAS) Total_ENTRADA
FROM MOVIM AS m
WHERE m.COMPROBANT LIKE '1%'
GROUP BY m.COMPROBANT,m.FECHA_TRS,m.COD_PROVEE,m.COD_AREA
And for the subquery data the fields
m.COMPROBANT, COUNT (m.COMPROBANT)Item_SALIDAS, m.FECHA_TRS,m.COD_PROVEE,m.COD_AREA,SUM(m.ENTRADAS) Total_SALIDAS
must be the same as the query but the WHERE of the subqueries must have
m.COMPROBANT LIKE '2%'
Resumed as reflected in the image
In the MOVIM table there is a field called COMPROBANT but in this there is data that starts with '1' and data that starts with '2' so what I want is that a column all start with '1' and another column those that begin with '2' that's why I put LIKE but it only comes out in a single column, both what starts with '1' and those that start with '2'
Thank you very much for your help in advance