Debashish Mahonta

Debashish Mahonta

  • 1.2k
  • 166
  • 4k

Concate two column into one column with sum and groupby

Sep 30 2024 4:54 AM

I have a table Tour Below

TourDate EmployeeName DeparturePlace ArrivalPlace DayAllowance
20/09/2024 Mr. Devid Dhaka Khulna 0
20/09/2024 Mr. Devid Khulna Dhaka 1
20/09/2024 Mr. Devid Rangpur Dhaka 1
20/09/2024 Mr. Devid Dhaka Rangpur 0
22/09/2024 Mr. Sam Rajshahi Rangapur 0
22/09/2024 Mr. Sam Rangpur Rajshahi 1

I want to concate two column into one column which TourDate is same Sum DayAllowance and GroupBy Date Like below:

TourDate Name VisitedPlace DayAllowance
20/09/2024 Mr. Devid From Dhaka To Khulna, Khulna To Dhaka, Rangpur To Dhaka and Dhaka to Rangpur 2
22/09/2024 Mr. Sam From Rajshahi To Rangpur and Rangpur To Rajshahi 1

TourDate and Name is Grouped when Same VisitedPlace Concate two column DeparturePlace and ArrivalPlace. DayAllowance is the Sum of DayAllowance column of Tour table. How can i Create that table?


Answers (7)