Number_of_Trips TIMEPART member_casual
46477 00 casual
30162 00 casual
18686 01 member
11112 01 casual
7619 05 member
12436 05 member
I have a table where TIMEPART is same for both member_casual, however whenever I am trying to write a query to get a result where the member and casual number of trips can come on separate column correponding to their TIME PART.
I am trying to get a result like this
TIMEPART members Casuals
00 46477 30162
01 18686 11112
05 7619 12436
2条答案
按热度按时间os8fio9y1#
If I understand you correctly you may get this result if you use PIVOT
prdp8dxp2#
You can group by
timepart
and usesum
with acase when
filter for the two categories:Note that your input example and desired output do not match -- probably because of some typos.