Hi
In a table i want to check if Student Id exists for more than 1 record.
Thanks
Hi
In a table i want to check if Student Id exists for more than 1 record.
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh KumarPosted Apr 17, 2023, 8:25 AM
Hello Ramco,
You can use having caluse with count() > 1 ;
Tuhin PaulPosted Apr 18, 2023, 7:16 AM
You can use aggregation pipelines to check if a student ID exists for more than one record. Depending on the specific NoSQL database you're using, the syntax and exact approach may vary.
This pipeline groups documents by the "student_id" field, calculates a count for each group, and filters out groups with a count of 1. The resulting output will include the IDs of any students that have more than one record.
Jay Krishna ReddyPosted Apr 17, 2023, 7:51 AM
This query will group the records in the "Students" table by the "StudentId" column, count the number of records for each group, and then return only the groups where the count is greater than 1.
Vishal JoshiPosted Apr 17, 2023, 7:15 AM
Hello
You can simply get a count of records that exists for the same id like the below query and in code, you can check if the count is greater than 1.
Server side you can check like below code
Thanks
Vishal
Amit MohantyPosted Apr 17, 2023, 6:37 AM
You can use a SQL query with the
GROUP BYclause and theHAVINGclause to check if a Student ID exists for more than one record in a table. Here's an example: