Count table records by column values
Options
![Alex Kornienko](https://us.v-cdn.net/6037124/user_avatars/2536296.jpg)
Alex Kornienko
Member ✭
Hi there! I need help with creating an API endpoint.
I have a report table where I reference other tables. In particular, I have Rating_1 column, which shows Rating values (integers, 1 to 5) selected by users. I'm trying to create an API endpoint that will return a count of report records for each rating value, even if it's 0 (which means no report records contain this Rating_Value in the "Rating_1" column.
[Знімок екрана 2021-12-15 о 14.15.44.png]
For example:
"experiment_id" 266
"option_id": 368
"Rating_Value" : 1
"reports_count": 2
"experiment_id" 266
"option_id": 368
"Rating_Value" : 2
"reports_count": 0
"experiment_id" 266
"option_id": 368
"Rating_Value" : 3
"reports_count": 5
etc.
[Знімок екрана 2021-12-15 о 14.16.04.png][Знімок екрана 2021-12-15 о 14.16.14.png][Знімок екрана 2021-12-15 о 14.15.19.png]
I suppose this could be done with Aggregate, but I couldn't achieve the result I need. Can anyone help me?
I have a report table where I reference other tables. In particular, I have Rating_1 column, which shows Rating values (integers, 1 to 5) selected by users. I'm trying to create an API endpoint that will return a count of report records for each rating value, even if it's 0 (which means no report records contain this Rating_Value in the "Rating_1" column.
[Знімок екрана 2021-12-15 о 14.15.44.png]
For example:
"experiment_id" 266
"option_id": 368
"Rating_Value" : 1
"reports_count": 2
"experiment_id" 266
"option_id": 368
"Rating_Value" : 2
"reports_count": 0
"experiment_id" 266
"option_id": 368
"Rating_Value" : 3
"reports_count": 5
etc.
[Знімок екрана 2021-12-15 о 14.16.04.png][Знімок екрана 2021-12-15 о 14.16.14.png][Знімок екрана 2021-12-15 о 14.15.19.png]
I suppose this could be done with Aggregate, but I couldn't achieve the result I need. Can anyone help me?
Comments
-
Hey there, this is how you would do it. Use an aggregate return type to get your groupings and count then an Addon to pull the value of your rating table:
-
Awesome, thank you !
-
can a video be produced on how to do this? I am new to the tool and am a visual learner.. thanks
-
Does anyone have an example of this recorded?
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback