Hi, hope every one is doing well. I am new to sql queries.
I need to calculate 'MARGIN', which is 'GrossProfit'/[price]*100 and then display the reuslt in the query. Can someone please help me !
SELECT
[Booking Product],
YEAR([Booking Conf Date]) AS 'BookingYear',
COUNT(DISTINCT [Booking Ref]) AS TotalBookings,
CONVERT (DECIMAL(17,2),(SUM(GBPCost))) AS Cost,
CONVERT (DECIMAL(17,2),(SUM(price))) AS Price,
CONVERT (DECIMAL(17,2),(SUM([Price]-[GBPCost]))) AS 'GrossProfit',
([Booked Adults]+[Booked Children]+[Booked Infants])AS 'PAX',
FROM
[A]
WHERE
BookingStatus = 'CONFIRMED'
GROUP BY
[GBPCost],[Price],[Booking Product],[Booking Conf Date],[Booked Adults],[Booked Children],[Booked Infants];
I need to calculate 'MARGIN', which is 'GrossProfit'/[price]*100 and then display the reuslt in the query. Can someone please help me !
SELECT
[Booking Product],
YEAR([Booking Conf Date]) AS 'BookingYear',
COUNT(DISTINCT [Booking Ref]) AS TotalBookings,
CONVERT (DECIMAL(17,2),(SUM(GBPCost))) AS Cost,
CONVERT (DECIMAL(17,2),(SUM(price))) AS Price,
CONVERT (DECIMAL(17,2),(SUM([Price]-[GBPCost]))) AS 'GrossProfit',
([Booked Adults]+[Booked Children]+[Booked Infants])AS 'PAX',
FROM
[A]
WHERE
BookingStatus = 'CONFIRMED'
GROUP BY
[GBPCost],[Price],[Booking Product],[Booking Conf Date],[Booked Adults],[Booked Children],[Booked Infants];