# Query Examples

Top open signals:

```sql
SELECT subject_name, signal_type, status, deadline, strategy, confidence
FROM allocation_signals
WHERE status IN ('open', 'active')
ORDER BY COALESCE(deadline, next_review, signal_date, '') DESC, confidence DESC
LIMIT 50;
```

One-hop neighborhood:

```sql
SELECT e.rel, e.weight, n.id, n.type, n.name
FROM edges e
JOIN nodes n ON n.id = CASE WHEN e.src = :node_id THEN e.dst ELSE e.src END
WHERE e.src = :node_id OR e.dst = :node_id
ORDER BY e.weight DESC
LIMIT 150;
```

Signal citations:

```sql
SELECT s.subject_name, c.source_path, c.excerpt, c.as_of_date
FROM allocation_signals s
JOIN citations c ON c.entity_type = 'signal' AND c.entity_id = s.id
WHERE s.id = :signal_id;
```

Browser graph overview:

```sql
SELECT n.id, n.type, n.name, e.rel, e.weight, other.name AS neighbor
FROM nodes n
JOIN edges e ON e.src = n.id OR e.dst = n.id
JOIN nodes other ON other.id = CASE WHEN e.src = n.id THEN e.dst ELSE e.src END
ORDER BY json_extract(n.attrs, '$.transcendence_score') DESC, e.weight DESC
LIMIT 320;
```
