Overpass query

A school will have a number of buildings and they will be located close by. I tried with overpass the query which can select only one of these buildings and skip the rest. But not Proper working. Can you tell me the query for that …

https://overpass-turbo.eu/s/ZEM

[out:json]
[timeout:25];

way({{bbox}})[amenity=school];

map_to_area ->.area;

(
  
   (
    node ["building"="school"]({{bbox}});
    way  ["building"="school"]({{bbox}});
   )->.scl;
  
   (
 
  (
    node ["building"="school"]["amenity"!~"."]({{bbox}});
    way  ["building"="school"]["amenity"!~"."]({{bbox}});
  );
  - 
  (
    // All nodes+ways with building=school and no amenity=* tag in area
    node ["building"="school"]["amenity"!~"."](area.area);
    way  ["building"="school"]["amenity"!~"."](area.area);    
  );)->.samp1;
   (
    node.samp1(around.scl:100);
    way.samp1(around.scl:100);
   )->.near;
  (.samp1; - .near;);
);
 out center;

Maybe you can try this query. Let me know if it doesn’t work for you

https://overpass-turbo.eu/s/14qS

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“building=school OR amenity=school”
*/
[out:json][timeout:25];
// gather results
(
  // query part for: “building=school”
  node["building"="school"]({{bbox}});
  way["building"="school"]({{bbox}});
  relation["building"="school"]({{bbox}});
  // query part for: “amenity=school”
  node["amenity"="school"]({{bbox}});
  way["amenity"="school"]({{bbox}});
  relation["amenity"="school"]({{bbox}});
);
// print results
out body;
>;
out skel qt;