Using COUNT returns the same value when counting two different columns
1
vote
1
answer
1588
views
I am new to SQL and am using it for a school project and would like some help.
I have a table with multiple columns about a fictional company that provides a bike sharing service. One of the rows I am trying to count is called member_casual which returns a string with either casual or member, that reports whether a user is a member or not. The second column I am trying to count is a string column called rideable_type that reports what kind of bike it has. I want to create a table that returns the number of kinds of bikes per each kind or rider, casual or member.
Here is my code:
SELECT member_casual,
COUNT(member_casual) AS member_type,
COUNT(rideable_type) AS electric_classic
FROM coursera-practice-356200.cycle_data.cycle_table1
GROUP BY member_casual
Here is my result:
| member_casual | member_type | electric_classic |
|---------------|-------------|------------------|
| casual | 21416 | 21416 |
|. member. |. 94193. |. 94193. |
I know my code is flawed, but I do not know where it is flawed. I also do not know why I got the same number when I am counting two different columns (member_casual
and rideable_type
) which should be very different numbers.
I guess what I am asking is for assistance on where my code is wrong and how to fix it.
Asked by YellingYeti
(11 rep)
Mar 1, 2023, 11:06 PM
Last activity: Mar 2, 2023, 01:05 PM
Last activity: Mar 2, 2023, 01:05 PM