Это мой пример таблицы, я хочу повернуть столбец сеанса и получить кол-во и сумму в одной строке
EmpName Session Qty Amount
--------------------------------------------------------
Arindam Dinner 3 195.00
Arindam Lunch 3 180.00
Arindam HI Tea 10 80.00
Arindam Snacks 10 370.00
мне нужен вывод в следующем формате
EmpName Dinner DinnerAmt Lunch LunchAmt HITea HITeaAmt Snacks SnacksAmt
------------------------------------------------------------------------------
Arindam 3 195.00 3 180.00 10 80.00 10 370.00
Это запрос.
select M_ccsv_Employee.vcName as EmpName,M_CAN_Session.vcName as SessionName,
sum(T_CanteenSub.iQty ) as Qty,sum( T_CanteenSub.dTotal ) as Total
from T_Canteen inner join M_ccsv_Employee
on T_Canteen.iEmpKey = M_ccsv_Employee.iKey
left join M_CAN_Session
on M_CAN_Session.iKey = T_Canteen.iSessionKey
inner join T_CanteenSub
on T_CanteenSub.iTransKey = T_Canteen.iKey
where ((right(CONVERT(date,T_Canteen.vcBillDate, 103),10)) between
(right(CONVERT(date,'01/11/2018', 103),10)) and
(right(CONVERT(date,'11/05/2019', 103),10))) and
M_ccsv_Employee.vcName = 'Arindam'
group by M_ccsv_Employee.vcName,M_CAN_Session.vcName