To get a key from realtime database you use getKey(). But i have to say you have to structure your data better. Also your query won't work as dates come before reg no. And ordering by date as shown will lead to issues for example 03-03-2021 will come before 20-02-2021.
final FirebaseDatabase databs= FirebaseDatabase.getInstance();
DatabaseReference p = databs.getReference("StudentAttend");
p.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dns) {
for (DataSnapshot snapshot : dns.getChildren()) {
String key = dns.getKey(); //this will get the date
//to get the student number within a date use above key
p.child(key).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dns) {
for (DataSnapshot snapshot : dns.getChildren()) {
String key = dns.getKey(); //this will get the reg_no
//get pick and drop here
}
}}}
}
To query data when you have a date
final FirebaseDatabase databs= FirebaseDatabase.getInstance();
DatabaseReference p = databs.getReference("StudentAttend").child(date_you_have); //then add listener here
If you don't have a date but have a reg no, follow above code to get the date key, then run query in there with
p.child(key).child(regnoyouhvae);
But i suggest you go over documentation again and read some articles on structuring your data, queries and more.