AnalystPath

Malformed Mesh Node Addresses

SQLHardSenior level~15 min

Problem

A sensor mesh logs a ping every time a node answers, recording the node's dotted address. A well-formed address is four numbers separated by dots, where each number is between 0 and 255 and carries no leading zero (so `7` is fine but `07` is not). An address is **malformed** if any segment exceeds 255, if any segment has a leading zero, or if it does not have exactly four segments. For every distinct malformed `node_address`, return it together with `invalid_count`, the number of ping rows that carried it. Order by `invalid_count` descending, then by `node_address` descending.

Tables

Example rows — the live problem includes the full dataset.

mesh_pings
ping_idnode_addresslatency_ms
110.20.30.4012
2260.5.6.730
310.20.030.4012

Expected output

Your answer should return 3 rows with the columns node_address, invalid_count.

Starter code (SQL)

SELECT *
FROM mesh_pings;

Solve this SQL question free

Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related SQL questions