D3 sql+executed, run 4: the query session

← back to the run

16 queries0 failed5 rounds
The opening prompt
## The data

You can't see the data, but you can query it. It is in DuckDB, in the tables below. Write DuckDB SQL.

To run queries, reply with one or more fenced blocks (```sql), and nothing else is needed:
each is run and its results sent back to you. You have up to 8 rounds of queries.
When you have what you need, reply with the final answers and no queries.

All columns are text (VARCHAR); dates are ISO strings.

- `entities` (497 rows): entity_id, name, lei, country, entity_type, parent_id, ultimate_parent_id, record_ids
- `instruments` (122 rows): instrument_id, description, issuer_id, guarantor_id, credit_risk_of, seniority, currency, local_currency, maturity
- `ratings` (869 rows): rated_id, rating_type, ccy_basis, rating, outlook, watch, action, valid_from, valid_to, action_id
- `ceilings` (2 rows): country, ceiling, valid_from
- `ancestors` (608 rows): entity_id, ancestor_id, levels_up

These tables are the data after its rules have been applied: duplicate records merged into one entity (record_ids lists the records each entity merges), and each rating with the period it held. An empty valid_to means the rating was still in force on 1 October 2026. ancestors lists every entity above each entity in its chain of parents, with how many levels up.

## Questions

Answer each question below from the data above. Start each answer on a new line with its
number in bold, like **Q1.**, give the direct answer first, then at most two sentences of
reasoning that cite the records (IDs) you relied on.

Then end with one JSON block (```json) holding the structured answer to each question listed
here, with exactly these fields, shaped like {"Q1": {"field": value}, ...}. Name entities by their record ID: the entity_id in the CSV files, or the part of the IRI after lad: in the RDF (E01, not Kestrel Energy plc).

- Q1: rating (a rating, or "none")
- Q2: downgraded ("yes", "no" or "depends")
- Q3: investment_grade ("yes", "no" or "depends"), rating (a rating, or "none")
- Q4: outlook (an outlook)
- Q5: risk_of (a record ID), rating (a rating, or "none")
- Q7: issuers (a list of record IDs)
- Q8: entities (a list of record IDs)
- Q9: count (a number)
- Q10: investment_grade ("yes", "no" or "depends")
- Q11: rating (a rating, or "none")
- Q12: rating (a rating, or "none")
- Q13: count (a number)
- Q14: rating (a rating, or "none")
- Q15: rating (a rating, or "none")
- Q16: changed ("yes", "no" or "depends")
- Q17: downgraded ("yes", "no" or "depends")
- Q18: issuers (a list of record IDs)
- Q19: issuers (a list of record IDs)
- Q20: in_default ("yes", "no" or "depends")
- Q21: entities (a list of record IDs)
- Q22: entities (a list of record IDs)
- Q23: rating (a rating, or "none")
- Q24: investment_grade ("yes", "no" or "depends")
- Q25: count (a number)
- Q26: rating (a rating, or "none")
- Q27: rating (a rating, or "none")
- Q28: rating (a rating, or "none")
- Q29: rating (a rating, or "none")
- Q30: entities (a list of record IDs)
- Q31: any ("yes", "no" or "depends")
- Q32: parent (a record ID)
- Q33: risk_of (a record ID), rating (a rating, or "none")
- Q34: same_group ("yes", "no" or "depends")
- Q35: count (a number)
- Q36: count (a number)
- Q37: count (a number)
- Q38: same ("yes", "no" or "depends")
- Q39: rating (a rating, or "none")
- Q40: count (a number)
- Q41: rating (a rating, or "none")
- Q42: country (a country code)
- Q43: count (a number)
- Q44: local_currency ("yes", "no" or "depends")
- Q45: above_ceiling ("yes", "no" or "depends")
- Q46: issuer_rating ("yes", "no" or "depends")
- Q47: rating (a rating, or "none")
- Q48: count (a number)
- Q49: parent (a record ID)
- Q50: count (a number)
- Q51: count (a number)
- Q52: count (a number)
- Q53: same_group ("yes", "no" or "depends")
- Q54: entities (a list of record IDs)
- Q55: count (a number)
- Q56: rating (a rating, or "none")
- Q57: entity (a record ID)
- Q58: entities (a list of record IDs)
- Q59: count (a number)
- Q60: risk_of (a record ID), same_group ("yes", "no" or "depends")
- Q61: count (a number)

Q1. What was Kestrel Energy's rating on 1 January 2025?
Q2. Has Kestrel Energy been downgraded in 2026?
Q3. Is Kestrel Energy's 2031 note investment grade?
Q4. What is Northwind Holdings' current outlook?
Q5. Whose credit risk does a holder of the Northwind Finance 2030 notes take, and how is it rated?
Q6. Why is Valdoria Telecom's foreign-currency rating lower than its local-currency rating?
Q7. Which issuers were downgraded in 2026?
Q8. Which entities were in default on 1 October 2026?
Q9. As of 1 October 2026, how many distinct issuers hold an issuer rating?
Q10. Is Valdoria Telecom investment grade?
Q11. What was Marlow Utilities' rating on 1 June 2025?
Q12. What was Marlow Utilities' rating on 1 January 2024?
Q13. How many times has Marlow Utilities been downgraded?
Q14. What was Halden Foods' rating on 1 January 2024?
Q15. What was Halden Bank's rating on 1 January 2026?
Q16. Has Marlow Utilities' rating changed since 1 January 2025?
Q17. Was Orrin Bank downgraded in 2026?
Q18. Which issuers were on Rating Watch Negative on 1 October 2026?
Q19. Which issuers had a Negative outlook on 1 October 2026?
Q20. Is Pellam Retail in default?
Q21. Which entities had an issuer rating at some point but no longer had one on 1 October 2026?
Q22. Which entities have ever been in default?
Q23. What is Kestrel Energy's short-term rating?
Q24. Is Kestrel Energy's issuer rating investment grade?
Q25. How many instruments held an investment-grade rating on 1 October 2026?
Q26. What is Corvenia Power's local-currency rating?
Q27. How is Corvenia Power's 2032 note rated?
Q28. What is the Republic of Corvenia's foreign-currency issuer rating?
Q29. What is the Republic of Valdoria's issuer rating?
Q30. Which entities had a foreign-currency issuer rating exactly at their country's ceiling on 1 October 2026?
Q31. Did any company have a foreign-currency issuer rating above its country's ceiling on 1 October 2026?
Q32. Who is Halden Leasing's ultimate parent?
Q33. Whose credit risk does a holder of the Halden Leasing 2028 notes take, and how is it rated?
Q34. Is Halden Foods part of the same group as Halden Bank?
Q35. How many entities are in the Halden group, the parent included?
Q36. How many entities are in the Northwind group, the parent included?
Q37. How many distinct legal entities does the data describe?
Q38. Are Orrin Bank AG and Orrin Bancorp Inc the same entity?
Q39. What is Northwind Holdings' current rating?
Q40. How many distinct issuers domiciled in GB held an issuer rating on 1 October 2026?
Q41. What is Brindle Capital's current rating?
Q42. In which country is Halden Bank domiciled?
Q43. How many distinct entities are domiciled in Luxembourg (LU)?
Q44. Is Valdoria Telecom's 2027 note a local-currency obligation?
Q45. Is Valdoria Telecom's 2027 note rated above what Valdoria's Country Ceiling allows?
Q46. Does Halden Leasing have an issuer rating?
Q47. How is Corvenia Power's 2034 note rated?
Q48. How many instruments held a rating on 1 October 2026?
Q49. Who is Cerid Rosor Holdings SA's ultimate parent?
Q50. How many levels of ownership separate Cerid Rosor Holdings SA from its ultimate parent?
Q51. How many entities are in the Cerid Group plc group, the parent included?
Q52. How many entities are in the Rotam Group Inc group, the parent included?
Q53. Are Belir Mining SA and Rotam Group Inc in the same group?
Q54. Which members of the Wonod Group SA group are domiciled in Valdoria (VD)?
Q55. If Valdoria (VD) came under stress, how many entities with an issuer rating in force have an entity domiciled in VD somewhere above them in their chain of parents?
Q56. What is the lowest current foreign-currency issuer rating held by any member of the Vesol Group BV group?
Q57. Which is the nearest entity that Cerid Guven Energy SA and Cerid Telecom SA both have in their chains of parents?
Q58. Which entities guarantee a note issued by an entity outside their own group?
Q59. How many entities in the Cerid Group plc group sit exactly three levels below the top?
Q60. Whose credit risk does a holder of the Cross-group 4.75% notes due 2031 take, and is that entity in the same group as the issuer?
Q61. How many members of the Cerid Group plc group, the top included, hold a foreign-currency issuer rating below investment grade?
The model
I'll start by exploring the data.

```sql
SELECT * FROM entities WHERE name ILIKE '%Kestrel%' OR name ILIKE '%Northwind%' OR name ILIKE '%Valdoria%' OR name ILIKE '%Marlow%' OR name ILIKE '%Halden%' OR name ILIKE '%Orrin%' OR name ILIKE '%Pellam%' OR name ILIKE '%Corvenia%' OR name ILIKE '%Brindle%' OR name ILIKE '%Cerid%' OR name ILIKE '%Rotam%' OR name ILIKE '%Belir%' OR name ILIKE '%Wonod%' OR name ILIKE '%Vesol%' ORDER BY name;
```
```sql
SELECT * FROM ceilings;
```
```sql
SELECT * FROM instruments WHERE description ILIKE '%Kestrel%' OR description ILIKE '%Northwind%' OR description ILIKE '%Valdoria%' OR description ILIKE '%Halden%' OR description ILIKE '%Corvenia%' OR description ILIKE '%Cross%' ORDER BY description;
```
Query results
Query 1:

| entity_id | name | lei | country | entity_type | parent_id | ultimate_parent_id | record_ids |
|---|---|---|---|---|---|---|---|
| E5083 | Belir Airlines plc | 815600VWRV7PTZ2G2598 | GB | CORP | E5075 | E5059 | E5083 |
| E5082 | Belir Bovid Telecom plc | 815600N0YPG44MRFH213 | GB | BANK | E5074 | E5059 | E5082 |
| E5067 | Belir Capital AG | 724500PEM92TFIBH3E89 | DE | CORP | E5063 | E5059 | E5067 |
| E5071 | Belir Chemicals SA | 724500EPR0DH4ZXK1N07 | FR | CORP | E5066 | E5059 | E5071 |
| E5080 | Belir Foods AG | 815600W19TGJNKXFFO22 | DE | CORP | E5072 | E5059 | E5080 |
| E5075 | Belir Gitid Industries plc | 815600DW5IX6LC8W8V29 | GB | CORP | E5068 | E5059 | E5075 |
| E5059 | Belir Group AG | 969500YPO4CFVEL1XX12 | DE | CORP |  |  | E5059 |
| E5063 | Belir Harem Property AG | 391200DIHCC3BA4VZZ12 | DE | CORP | E5060 | E5059 | E5063 |
| E5064 | Belir Holdings plc | 724500Q0JKSMWBXVBU93 | GB | CORP | E5061 | E5059 | E5064 |
| E5074 | Belir Industries plc | 549300KXQ2S560AVV453 | GB | CORP | E5068 | E5059 | E5074 |
| E5072 | Belir Katin Telecom AG | 815600R2EBVJ16RD3A20 | DE | CORP | E5067 | E5059 | E5072 |
| E5068 | Belir Kator Energy plc | 969500LH6R0LMYUZA394 | GB | CORP | E5064 | E5059 | E5068 |
| E5084 | Belir Luton Media SA | 815600NALYO1JPB0Y303 | FR | BANK | E5076 | E5059 | E5084 |
| E5077 | Belir Media SA | 213800PX54IYKA21SV31 | FR | CORP | E5069 | E5059 | E5077 |
| E5062 | Belir Mining SA | 54930011OTFCAUKB0A28 | FR | CORP | E5060 | E5059 | E5062 E5168 |
| E5065 | Belir Nelad Property AG | 549300L03V06VLA93J12 | DE | CORP | E5061 | E5059 | E5065 |
| E5076 | Belir Property SA | 96950092K7EM4MPGLP04 | FR | CORP | E5069 | E5059 | E5076 |
| E5073 | Belir Puvir Mining plc | 549300Z4E2ZBV3ZWA751 | GB | CORP | E5067 | E5059 | E5073 |
| E5060 | Belir Retail AG | 549300PQXT9OXKZVXP03 | DE | CORP | E5059 | E5059 | E5060 |
| E5070 | Belir Rusin Media SA | 8156004IQIH39FK9VH78 | FR | CORP | E5066 | E5059 | E5070 |
| E5085 | Belir Rutel Water SA | 213800K6R3NB1ZT7Y709 | CV | CORP | E5077 | E5059 | E5085 |
| E5066 | Belir Shipping SA | 2138006F3FLNO4C1FU85 | FR | CORP | E5062 | E5059 | E5066 |
| E5079 | Belir Sitom Logistics SA | 213800N76YAEEVTGC136 | FR | CORP | E5071 | E5059 | E5079 |
| E5061 | Belir Steel Inc | 5493004QWM1AN9Q59M90 | US | BANK | E5059 | E5059 | E5061 |
| E5078 | Belir Vasin Water plc | 969500OGDTR8B14SH139 | GB | BANK | E5070 | E5059 | E5078 |
| E5081 | Belir Vusad Telecom SA | 549300C58DC34KK7FK00 | VD | CORP | E5073 | E5059 | E5081 |
| E5069 | Belir Water SA | 391200PZ4I0VQJK2W457 | FR | CORP | E5065 | E5059 | E5069 |
| E5008 | Cerid Airlines BV | 815600M8RE9386DDQB31 | NL | CORP | E5003 | E5001 | E5008 |
| E5051 | Cerid Butad Capital SA | 969500P4S8FH9839YS39 | FR | CORP | E5039 | E5001 | E5051 |
| E5019 | Cerid Buvom Mining plc | 2138002W9KTVILKQ8Q89 | GB | CORP | E5009 | E5001 | E5019 |
| E5036 | Cerid Calin Energy SpA | 549300RJ7KMPDJVQY167 | IT | CORP | E5024 | E5001 | E5036 |
| E5056 | Cerid Capital plc | 391200Q0XXMZJQSOR362 | GB | CORP | E5044 | E5001 | E5056 |
| E5005 | Cerid Chemicals SA | 391200B1GR4AGTV5WY99 | VD | CORP | E5002 | E5001 | E5005 E5167 |
| E5058 | Cerid Cirad Industries BV | 391200XLOZO7S6T1FI61 | NL | BANK | E5046 | E5001 | E5058 |
| E5045 | Cerid Curel Water SA | 7245006QVOPQQK3JUP45 | CV | CORP | E5033 | E5001 | E5045 |
| E5023 | Cerid Dilal Utilities SA | 549300MXQ7UU7852PG70 | VD | CORP | E5011 | E5001 | E5023 |
| E5041 | Cerid Dolem Mining AG | 391200FXD4CH3FVZ4165 | DE | BANK | E5029 | E5001 | E5041 |
| E5002 | Cerid Energy plc | 3912006ACANJUP8PLJ39 | GB | CORP | E5001 | E5001 | E5002 |
| E5024 | Cerid Fatal Shipping SA | 39120041ZCI02VDN2I18 | VD | CORP | E5012 | E5001 | E5024 |
| E5025 | Cerid Fater Media SA | 213800AXPZD5MSP2GW32 | ES | CORP | E5013 | E5001 | E5025 |
| E5042 | Cerid Feral Property BV | 724500N6QZUJJJ1BJI79 | NL | BANK | E5030 | E5001 | E5042 |
| E5006 | Cerid Foods plc | 969500HZQBDFIIHLYK06 | GB | BANK | E5002 | E5001 | E5006 |
| E5050 | Cerid Futir Utilities BV | 213800KKF07D3TEWYS82 | NL | BANK | E5038 | E5001 | E5050 |
| E5028 | Cerid Galon Chemicals BV | 724500EVQNRETR9CVD02 | NL | BANK | E5016 | E5001 | E5028 |
| E5010 | Cerid Gator Steel Inc | 724500E2OQMMMZVTBS53 | US | CORP | E5004 | E5001 | E5010 |
| E5012 | Cerid Gevin Pharma SA | 549300TPHB19IJU6VV67 | VD | CORP | E5005 | E5001 | E5012 |
| E5046 | Cerid Gevom Media BV | 5493004EWDCN8OTFZZ22 | NL | CORP | E5034 | E5001 | E5046 |
| E5055 | Cerid Gosim Media SA | 391200627RBIC2DTG305 | CV | CORP | E5043 | E5001 | E5055 |
| E5001 | Cerid Group plc | 815600F48PANJQE75352 | GB | CORP |  |  | E5001 |
| E5014 | Cerid Gusom Pharma SpA | 724500YWGS7BR1AKHD13 | IT | CORP | E5006 | E5001 | E5014 |
| E5011 | Cerid Guven Energy SA | 391200IX7WB68Q29NJ46 | VD | CORP | E5005 | E5001 | E5011 |
| E5007 | Cerid Holdings BV | 391200Q98UGZZQTV1C88 | NL | CORP | E5003 | E5001 | E5007 |
| E5038 | Cerid Holen Chemicals BV | 969500HETRKT6OQMNS48 | NL | CORP | E5026 | E5001 | E5038 |
| E5037 | Cerid Holom Water SA | 2138003NRPV4IDSP9314 | ES | CORP | E5025 | E5001 | E5037 |
| E5026 | Cerid Hosad Retail Inc | 724500GF9ADSAA20FI77 | US | CORP | E5014 | E5001 | E5026 |
| E5027 | Cerid Hutem Water plc | 391200TO1KK187R1JQ78 | GB | CORP | E5015 | E5001 | E5027 |
| E5022 | Cerid Industries Inc | 213800S7QJ9EVK96PK05 | US | CORP | E5010 | E5001 | E5022 |
| E5009 | Cerid Leror Logistics plc | 96950033222B9BRCGP58 | GB | CORP | E5004 | E5001 | E5009 |
| E5054 | Cerid Linin Media BV | 549300UVWD2URAQCNQ18 | NL | BANK | E5042 | E5001 | E5054 |
| E5015 | Cerid Logistics BV | 969500C1TQV008QIYL28 | NL | CORP | E5007 | E5001 | E5015 |
(99 more rows not shown)

Query 2:

| country | ceiling | valid_from |
|---|---|---|
| CV | A | 2024-01-01 |
| VD | BB | 2025-04-01 |

Query 3:

| instrument_id | description | issuer_id | guarantor_id | credit_risk_of | seniority | currency | local_currency | maturity |
|---|---|---|---|---|---|---|---|---|
| I08 | Corvenia Power 6.00% notes due 2034 | E15 |  | E15 | SU | USD | no | 2034-09-01 |
| I06 | Corvenia Power 7.10% notes due 2032 | E15 |  | E15 | SUB | USD | no | 2032-02-15 |
| I5007 | Cross-group 4.75% notes due 2031 | E5133 | E5145 | E5145 | SU | USD | no | 2031-06-30 |
| I05 | Halden Leasing 2.90% notes due 2028 | E11 | E10 | E10 | SU | EUR | no | 2028-06-30 |
| I01 | Kestrel Energy 4.50% notes due 2030 | E01 |  | E01 | SU | GBP | no | 2030-03-15 |
| I02 | Kestrel Energy 6.25% notes due 2031 | E01 |  | E01 | SUB | GBP | no | 2031-09-30 |
| I03 | Northwind Finance 3.75% notes due 2030 | E04 | E02 | E02 | SU | EUR | no | 2030-05-01 |
| I07 | Valdoria Telecom 4.25% notes due 2027 | E05 |  | E05 | SU | XVD | yes | 2027-08-31 |
| I04 | Valdoria Telecom 5.00% notes due 2029 | E05 |  | E05 | SU | USD | no | 2029-11-20 |

Run more queries, or give the final answers.
The model
<sql>
SELECT * FROM entities WHERE entity_id NOT LIKE 'E50%' AND entity_id NOT LIKE 'E51%' ORDER BY entity_id;
```
```sql
SELECT * FROM ratings WHERE rated_id LIKE 'E0%' OR rated_id LIKE 'E1%' OR rated_id LIKE 'I0%' ORDER BY rated_id, rating_type, ccy_basis, valid_from;
```
```sql
SELECT rating_type, ccy_basis, count(*) FROM ratings GROUP BY ALL;
```
Query results
Query 1:

| rated_id | rating_type | ccy_basis | rating | outlook | watch | action | valid_from | valid_to | action_id |
|---|---|---|---|---|---|---|---|---|---|
| E01 | LTIDR | FC | A- | STA |  | AS | 2024-03-12 | 2025-06-20 | A01 |
| E01 | LTIDR | FC | BBB | STA |  | DG | 2025-06-20 | 2026-02-10 | A02 |
| E01 | LTIDR | FC | BBB | NEG |  | AF | 2026-02-10 |  | A03 |
| E01 | STIDR | FC | F2 |  |  | AF | 2026-02-10 |  | A04 |
| E02 | LTIDR | FC | A | STA |  | AS | 2023-11-01 | 2025-09-15 | A08 |
| E02 | LTIDR | FC | A | POS |  | AF | 2025-09-15 |  | A09 |
| E05 | LTIDR | FC | BB | STA |  | AS | 2025-04-01 |  | A14 |
| E05 | LTIDR | LC | BBB- | STA |  | AS | 2025-04-01 |  | A13 |
| E06 | LTIDR | FC | A- | STA |  | AS | 2024-05-01 | 2026-09-03 | A16 |
| E06 | LTIDR | FC | A- |  | RWN | RW | 2026-09-03 |  | A17 |
| E07 | LTIDR | FC | BB | STA |  | AS | 2024-01-10 | 2026-05-12 | A18 |
| E07 | LTIDR | FC | WD |  |  | WD | 2026-05-12 |  | A19 |
| E08 | LTIDR | FC | B | STA |  | AS | 2024-06-01 | 2026-01-20 | A20 |
| E08 | LTIDR | FC | CCC |  |  | DG | 2026-01-20 | 2026-07-08 | A21 |
| E08 | LTIDR | FC | RD |  |  | DG | 2026-07-08 |  | A22 |
| E09 | LTIDR | FC | A | STA |  | AS | 2023-05-01 | 2026-03-01 | A24 |
| E09 | LTIDR | FC | A | NEG |  | AF | 2026-03-01 |  | A25 |
| E10 | LTIDR | FC | A- | STA |  | AS | 2023-05-01 | 2026-04-15 | A26 |
| E10 | LTIDR | FC | BBB+ | STA |  | DG | 2026-04-15 |  | A27 |
| E1001 | LTIDR | FC | A+ | STA |  | AS | 2022-08-18 | 2025-07-20 | A1001 |
| E1001 | LTIDR | FC | WD |  |  | WD | 2025-07-20 |  | A1002 |
| E1003 | LTIDR | FC | A | STA |  | AS | 2024-07-05 |  | A1003 |
| E1004 | LTIDR | FC | BB | STA |  | AS | 2023-05-02 |  | A1004 |
| E1005 | LTIDR | FC | BBB- | STA |  | AS | 2022-05-02 | 2023-03-19 | A1005 |
| E1005 | LTIDR | FC | BB+ | POS |  | DG | 2023-03-19 | 2025-08-02 | A1006 |
| E1005 | LTIDR | FC | BB | NEG |  | DG | 2025-08-02 |  | A1007 |
| E1006 | LTIDR | FC | AA- | STA |  | AS | 2025-08-26 | 2026-04-15 | A1008 |
| E1006 | LTIDR | FC | AA | STA |  | UG | 2026-04-15 | 2026-06-17 | A1009 |
| E1006 | LTIDR | FC | AA |  | RWN | RW | 2026-06-17 |  | A1010 |
| E1007 | LTIDR | FC | BB- | STA |  | AS | 2023-06-03 | 2026-06-27 | A1012 |
| E1007 | LTIDR | FC | WD |  |  | WD | 2026-06-27 |  | A1013 |
| E1008 | LTIDR | FC | BBB- | STA |  | AS | 2022-12-09 |  | A1015 |
| E1009 | LTIDR | FC | A | STA |  | AS | 2022-05-02 |  | A1017 |
| E1010 | LTIDR | FC | BBB- | STA |  | AS | 2023-08-18 |  | A1019 |
| E1011 | LTIDR | FC | B+ | STA |  | AS | 2025-12-13 |  | A1020 |
| E1012 | LTIDR | FC | BB | STA |  | AS | 2024-11-09 | 2025-04-03 | A1021 |
| E1012 | LTIDR | FC | BB |  | RWN | RW | 2025-04-03 | 2026-02-06 | A1022 |
| E1012 | LTIDR | FC | BB+ | POS |  | UG | 2026-02-06 |  | A1023 |
| E1013 | LTIDR | FC | BB- | STA |  | AS | 2022-06-02 | 2025-07-09 | A1025 |
| E1013 | LTIDR | FC | BB- |  | RWN | RW | 2025-07-09 |  | A1026 |
| E1014 | LTIDR | FC | AA- | STA |  | AS | 2025-07-11 |  | A1028 |
| E1015 | LTIDR | FC | BBB+ | STA |  | AS | 2025-11-24 |  | A1030 |
| E1016 | LTIDR | FC | B+ | STA |  | AS | 2022-06-10 | 2025-06-28 | A1031 |
| E1016 | LTIDR | FC | B+ | STA |  | AF | 2025-06-28 |  | A1032 |
| E1017 | LTIDR | FC | AA- | STA |  | AS | 2022-03-03 | 2024-08-09 | A1034 |
| E1017 | LTIDR | FC | AA | STA |  | UG | 2024-08-09 | 2025-04-20 | A1035 |
| E1017 | LTIDR | FC | AA | STA |  | AF | 2025-04-20 |  | A1036 |
| E1018 | LTIDR | FC | A | STA |  | AS | 2025-08-11 |  | A1037 |
| E1019 | LTIDR | FC | BB+ | STA |  | AS | 2022-12-11 |  | A1039 |
| E1019 | LTIDR | LC | BBB- | STA |  | AS | 2022-12-11 | 2024-02-08 | A1040 |
| E1019 | LTIDR | LC | BBB- |  | RWN | RW | 2024-02-08 | 2024-03-20 | A1041 |
| E1019 | LTIDR | LC | BBB- |  | RWN | RW | 2024-03-20 |  | A1042 |
| E1020 | LTIDR | FC | A- | STA |  | AS | 2024-06-15 |  | A1043 |
| E1021 | LTIDR | FC | BBB- | STA |  | AS | 2022-06-19 | 2025-11-08 | A1045 |
| E1021 | LTIDR | FC | WD |  |  | WD | 2025-11-08 |  | A1046 |
| E1023 | LTIDR | FC | A- | STA |  | AS | 2022-06-05 | 2023-03-02 | A1048 |
| E1023 | LTIDR | FC | BBB+ | POS |  | DG | 2023-03-02 | 2023-03-24 | A1049 |
| E1023 | LTIDR | FC | BBB | STA |  | DG | 2023-03-24 |  | A1050 |
| E1024 | LTIDR | FC | B+ | STA |  | AS | 2022-06-18 |  | A1052 |
| E1025 | LTIDR | FC | BB- | STA |  | AS | 2022-07-17 |  | A1053 |
(582 more rows not shown)

Query 2:

| rating_type | ccy_basis | count_star() |
|---|---|---|
| LTIDR | LC | 34 |
| STIDR | FC | 1 |
| INST |  | 117 |
| LTIDR | FC | 717 |

Run more queries, or give the final answers.
The model
```sql
SELECT * FROM entities WHERE entity_id NOT LIKE 'E50%' AND entity_id NOT LIKE 'E51%' AND entity_id NOT LIKE 'E1___' ORDER BY entity_id;
```
```sql
SELECT * FROM ratings WHERE rated_id LIKE 'I%' ORDER BY rated_id, valid_from;
```
```sql
SELECT * FROM ratings WHERE rated_id IN ('E03','E04','E11','E12','E13','E14','E15','E16','E17','E18','E19','E20') ORDER BY rated_id, valid_from;
```
```sql
SELECT * FROM instruments WHERE issuer_id NOT IN ('E01','E04','E05','E11','E15') OR guarantor_id<>'' ORDER BY instrument_id;
```
Query results
Query 1:

| entity_id | name | lei | country | entity_type | parent_id | ultimate_parent_id | record_ids |
|---|---|---|---|---|---|---|---|
| CV | Republic of Corvenia |  | CV | SOV |  |  | CV |
| E01 | Kestrel Energy plc | 7245002OOPBG04092E43 | GB | CORP |  |  | E01 |
| E02 | Northwind Holdings plc | 213800PHEIYNJMHTDV74 | GB | CORP |  |  | E02 E03 |
| E04 | Northwind Finance BV | 213800LA5RYJLGXV2T85 | NL | FINSUB | E02 | E02 | E04 |
| E05 | Valdoria Telecom SA | 391200LESH03LMOY2U61 | VD | CORP |  |  | E05 |
| E06 | Orrin Bank AG | 549300AMVE3VRVG7HK43 | DE | BANK |  |  | E06 |
| E07 | Pellam Retail Ltd | 969500B6IUACELPI2291 | GB | CORP |  |  | E07 |
| E08 | Saxby Shipping SA | 969500KOTZ1JFIZSG796 | GR | CORP |  |  | E08 |
| E09 | Halden Group plc | 815600ASM9EHDG931T89 | GB | CORP |  |  | E09 |
| E10 | Halden Bank AG | 391200QYPVFF2O9K2039 | LU | BANK | E09 | E09 | E10 E17 |
| E11 | Halden Leasing SA | 549300XBZH4ULO9MQV55 | FR | FINSUB | E10 | E09 | E11 |
| E12 | Halden Foods Ltd | 213800IJDL4OJ4DG5T19 | GB | CORP |  |  | E12 |
| E13 | Orrin Bancorp Inc | 815600O8X8K2F154N214 | US | BANK |  |  | E13 |
| E14 | Marlow Utilities plc | 3912005AH2C1I9YF8106 | GB | CORP |  |  | E14 |
| E15 | Corvenia Power SA | 213800PBQVHVBBH6GV02 | CV | CORP |  |  | E15 |
| VD | Republic of Valdoria |  | VD | SOV |  |  | VD |

Query 2:

| rated_id | rating_type | ccy_basis | rating | outlook | watch | action | valid_from | valid_to | action_id |
|---|---|---|---|---|---|---|---|---|---|
| I01 | INST |  | A- |  |  | AS | 2024-03-12 | 2025-06-20 | A05 |
| I01 | INST |  | BBB |  |  | DG | 2025-06-20 |  | A06 |
| I02 | INST |  | BBB |  |  | AS | 2024-03-12 | 2025-06-20 | A23 |
| I02 | INST |  | BB+ |  |  | DG | 2025-06-20 |  | A07 |
| I03 | INST |  | A |  |  | AS | 2023-11-01 | 2025-09-15 | A10 |
| I03 | INST |  | A |  |  | AF | 2025-09-15 |  | A11 |
| I04 | INST |  | BB |  |  | AS | 2025-04-01 |  | A15 |
| I05 | INST |  | A- |  |  | AS | 2023-06-01 | 2026-04-15 | A28 |
| I05 | INST |  | BBB+ |  |  | DG | 2026-04-15 |  | A29 |
| I06 | INST |  | A- |  |  | AS | 2024-03-01 |  | A42 |
| I07 | INST |  | BBB- |  |  | AS | 2025-04-01 |  | A45 |
| I1002 | INST |  | BB- |  |  | AS | 2023-06-03 |  | A1014 |
| I1003 | INST |  | BBB- |  |  | AS | 2022-12-09 |  | A1016 |
| I1004 | INST |  | A |  |  | AS | 2022-05-02 |  | A1018 |
| I1005 | INST |  | BB |  |  | AS | 2024-11-09 |  | A1024 |
| I1006 | INST |  | B+ |  |  | AS | 2022-06-02 |  | A1027 |
| I1009 | INST |  | A- |  |  | AS | 2025-08-11 |  | A1038 |
| I1010 | INST |  | A- |  |  | AS | 2024-06-15 |  | A1044 |
| I1011 | INST |  | BBB- |  |  | AS | 2022-06-19 |  | A1047 |
| I1013 | INST |  | BB+ |  |  | AS | 2025-12-06 |  | A1065 |
| I1014 | INST |  | A- |  |  | AS | 2022-10-23 |  | A1073 |
| I1016 | INST |  | A+ |  |  | AS | 2023-01-01 |  | A1086 |
| I1017 | INST |  | BB |  |  | AS | 2022-12-22 |  | A1096 |
| I1018 | INST |  | BB+ |  |  | AS | 2022-04-18 |  | A1098 |
| I1019 | INST |  | BB+ |  |  | AS | 2025-09-02 |  | A1100 |
| I1020 | INST |  | BB+ |  |  | AS | 2024-03-25 |  | A1107 |
| I1022 | INST |  | BB+ |  |  | AS | 2022-07-09 |  | A1147 |
| I1023 | INST |  | B |  |  | AS | 2023-01-11 |  | A1153 |
| I1024 | INST |  | BB |  |  | AS | 2022-05-09 |  | A1165 |
| I1025 | INST |  | BB+ |  |  | AS | 2022-02-01 |  | A1168 |
| I1026 | INST |  | BB+ |  |  | AS | 2022-06-05 |  | A1172 |
| I1027 | INST |  | BBB |  |  | AS | 2024-12-28 |  | A1177 |
| I1028 | INST |  | A- |  |  | AS | 2022-04-17 |  | A1183 |
| I1029 | INST |  | A+ |  |  | AS | 2025-02-24 |  | A1185 |
| I1030 | INST |  | BBB- |  |  | AS | 2024-10-14 |  | A1188 |
| I1031 | INST |  | B |  |  | AS | 2022-07-14 |  | A1191 |
| I1032 | INST |  | BB- |  |  | AS | 2024-07-05 |  | A1195 |
| I1033 | INST |  | B |  |  | AS | 2024-12-05 |  | A1224 |
| I1034 | INST |  | A- |  |  | AS | 2025-03-25 |  | A1235 |
| I1035 | INST |  | BB |  |  | AS | 2024-09-12 |  | A1248 |
| I1036 | INST |  | A+ |  |  | AS | 2022-09-01 |  | A1252 |
| I1037 | INST |  | BBB- |  |  | AS | 2022-10-15 |  | A1256 |
| I1038 | INST |  | BBB+ |  |  | AS | 2025-11-01 |  | A1281 |
| I1039 | INST |  | AA- |  |  | AS | 2023-01-03 |  | A1302 |
| I1040 | INST |  | A+ |  |  | AS | 2023-02-16 |  | A1307 |
| I1041 | INST |  | BB |  |  | AS | 2025-06-04 |  | A1314 |
| I1042 | INST |  | A+ |  |  | AS | 2025-04-10 |  | A1321 |
| I1043 | INST |  | A+ |  |  | AS | 2025-11-14 |  | A1323 |
| I1044 | INST |  | BB- |  |  | AS | 2025-02-14 |  | A1333 |
| I1045 | INST |  | A |  |  | AS | 2025-09-01 |  | A1335 |
| I1047 | INST |  | A+ |  |  | AS | 2025-10-19 |  | A1347 |
| I1048 | INST |  | BB+ |  |  | AS | 2023-09-18 |  | A1351 |
| I1050 | INST |  | BBB- |  |  | AS | 2023-07-22 |  | A1363 |
| I1051 | INST |  | B+ |  |  | AS | 2023-09-26 |  | A1399 |
| I1052 | INST |  | BBB |  |  | AS | 2023-06-07 |  | A1402 |
| I1053 | INST |  | BBB- |  |  | AS | 2023-07-09 |  | A1405 |
| I1054 | INST |  | A+ |  |  | AS | 2025-04-07 |  | A1413 |
| I1055 | INST |  | A |  |  | AS | 2024-02-23 |  | A1419 |
| I1056 | INST |  | A- |  |  | AS | 2025-03-28 |  | A1431 |
| I1057 | INST |  | AA- |  |  | AS | 2025-05-09 |  | A1434 |
(57 more rows not shown)

Query 3:

| rated_id | rating_type | ccy_basis | rating | outlook | watch | action | valid_from | valid_to | action_id |
|---|---|---|---|---|---|---|---|---|---|
| E12 | LTIDR | FC | BB- | STA |  | AS | 2024-02-01 | 2025-08-01 | A30 |
| E12 | LTIDR | FC | BB | STA |  | UG | 2025-08-01 |  | A31 |
| E13 | LTIDR | FC | BBB | STA |  | AS | 2024-07-01 |  | A32 |
| E14 | LTIDR | FC | A- | STA |  | AS | 2023-01-15 | 2024-09-30 | A34 |
| E14 | LTIDR | FC | BBB+ | STA |  | DG | 2024-09-30 | 2025-11-20 | A36 |
| E14 | LTIDR | FC | BBB+ |  | RWN | RW | 2025-11-20 | 2026-05-01 | A35 |
| E14 | LTIDR | FC | BBB+ | STA |  | AF | 2026-05-01 |  | A33 |
| E15 | LTIDR | FC | A | STA |  | AS | 2024-03-01 |  | A41 |
| E15 | LTIDR | LC | A+ | STA |  | AS | 2024-03-01 |  | A40 |

Query 4:

| instrument_id | description | issuer_id | guarantor_id | credit_risk_of | seniority | currency | local_currency | maturity |
|---|---|---|---|---|---|---|---|---|
| I03 | Northwind Finance 3.75% notes due 2030 | E04 | E02 | E02 | SU | EUR | no | 2030-05-01 |
| I05 | Halden Leasing 2.90% notes due 2028 | E11 | E10 | E10 | SU | EUR | no | 2028-06-30 |
| I1001 | Soson Airlines 5.50% notes due 2031 | E1006 |  | E1006 | SUB | USD | no | 2035-06-30 |
| I1002 | Golod Property 8.75% notes due 2031 | E1007 |  | E1007 | SU | USD | no | 2033-06-30 |
| I1003 | Sotil Retail 3.00% notes due 2031 | E1008 |  | E1008 | SU | GBP | no | 2034-06-30 |
| I1004 | Malam Chemicals 2.25% notes due 2035 | E1009 |  | E1009 | SU | USD | no | 2028-06-30 |
| I1005 | Posad Industries 4.00% notes due 2033 | E1012 |  | E1012 | SU | EUR | no | 2031-06-30 |
| I1006 | Pisol Pharma 4.75% notes due 2030 | E1013 |  | E1013 | SUB | USD | no | 2030-06-30 |
| I1007 | Toral Utilities 7.75% notes due 2028 | E1014 |  | E1014 | SU | EUR | no | 2033-06-30 |
| I1008 | Ponar Telecom 4.75% notes due 2035 | E1016 |  | E1016 | SU | EUR | no | 2033-06-30 |
| I1009 | Tosem Mining 2.75% notes due 2031 | E1018 |  | E1018 | SUB | USD | no | 2036-06-30 |
| I1010 | Finel Media 6.50% notes due 2035 | E1020 |  | E1020 | SU | EUR | no | 2036-06-30 |
| I1011 | Niner Pharma 3.25% notes due 2029 | E1021 |  | E1021 | SU | USD | no | 2035-06-30 |
| I1012 | Heled Water 6.25% notes due 2030 | E1023 |  | E1023 | SU | GBP | no | 2031-06-30 |
| I1013 | Kuvir Logistics 2.00% notes due 2027 | E1031 |  | E1031 | SU | EUR | no | 2027-06-30 |
| I1014 | Kavod Utilities 2.50% notes due 2032 | E1035 |  | E1035 | SU | USD | no | 2036-06-30 |
| I1015 | Lanon Telecom 4.75% notes due 2033 | E1038 |  | E1038 | SUB | EUR | no | 2032-06-30 |
| I1016 | Hiral Steel 6.00% notes due 2035 | E1041 |  | E1041 | SU | USD | no | 2034-06-30 |
| I1017 | Lised Pharma 4.50% notes due 2036 | E1048 |  | E1048 | SU | EUR | no | 2029-06-30 |
| I1018 | Paser Utilities 3.75% notes due 2027 | E1049 |  | E1049 | SUB | GBP | no | 2034-06-30 |
| I1019 | Sunar Holdings 8.50% notes due 2036 | E1050 |  | E1050 | SUB | USD | no | 2034-06-30 |
| I1020 | Witad Steel 5.00% notes due 2033 | E1052 |  | E1052 | SU | EUR | no | 2027-06-30 |
| I1021 | Duver Shipping 8.50% notes due 2032 | E1056 |  | E1056 | SU | EUR | no | 2030-06-30 |
| I1022 | Levem Foods 6.50% notes due 2035 | E1067 |  | E1067 | SUB | EUR | no | 2030-06-30 |
| I1023 | Mored Utilities 4.25% notes due 2032 | E1071 |  | E1071 | SUB | USD | no | 2033-06-30 |
| I1024 | Ganed Holdings 5.75% notes due 2035 | E1077 |  | E1077 | SU | EUR | no | 2032-06-30 |
| I1025 | Menir Shipping 7.50% notes due 2028 | E1078 |  | E1078 | SUB | EUR | no | 2034-06-30 |
| I1026 | Nevar Property 6.75% notes due 2036 | E1079 |  | E1079 | SU | GBP | no | 2028-06-30 |
| I1027 | Gilen Capital 2.00% notes due 2031 | E1082 |  | E1082 | SUB | USD | no | 2034-06-30 |
| I1028 | Givim Mining 5.75% notes due 2036 | E1085 |  | E1085 | SU | EUR | no | 2034-06-30 |
| I1029 | Gorar Steel 7.25% notes due 2033 | E1086 |  | E1086 | SUB | USD | no | 2035-06-30 |
| I1030 | Vitid Holdings 5.75% notes due 2032 | E1087 |  | E1087 | SU | EUR | no | 2034-06-30 |
| I1031 | Koved Holdings 2.50% notes due 2032 | E1088 |  | E1088 | SUB | EUR | no | 2033-06-30 |
| I1032 | Getel Utilities 7.25% notes due 2033 | E1090 |  | E1090 | SU | USD | no | 2032-06-30 |
| I1033 | Vavam Pharma 8.75% notes due 2032 | E1103 |  | E1103 | SUB | USD | no | 2032-06-30 |
| I1034 | Kisil Logistics 8.50% notes due 2031 | E1108 |  | E1108 | SU | EUR | no | 2033-06-30 |
| I1035 | Verod Logistics 3.00% notes due 2035 | E1114 |  | E1114 | SU | GBP | no | 2029-06-30 |
| I1036 | Piren Foods 2.50% notes due 2030 | E1115 |  | E1115 | SU | USD | no | 2033-06-30 |
| I1037 | Reter Shipping 8.00% notes due 2028 | E1118 |  | E1118 | SU | EUR | no | 2027-06-30 |
| I1038 | Conan Capital 4.75% notes due 2033 | E1131 |  | E1131 | SU | EUR | no | 2031-06-30 |
| I1039 | Larid Steel 8.50% notes due 2028 | E1141 |  | E1141 | SU | GBP | no | 2033-06-30 |
| I1040 | Woner Media 5.75% notes due 2027 | E1143 |  | E1143 | SUB | EUR | no | 2027-06-30 |
| I1041 | Kanim Pharma 3.25% notes due 2033 | E1145 |  | E1145 | SUB | EUR | no | 2036-06-30 |
| I1042 | Daren Mining 5.75% notes due 2030 | E1147 |  | E1147 | SU | EUR | no | 2035-06-30 |
| I1043 | Honel Shipping 4.50% notes due 2028 | E1149 |  | E1149 | SUB | EUR | no | 2029-06-30 |
| I1044 | Wavad Foods 6.75% notes due 2035 | E1155 |  | E1155 | SU | USD | no | 2036-06-30 |
| I1045 | Ruven Airlines 5.75% notes due 2032 | E1156 |  | E1156 | SUB | EUR | no | 2036-06-30 |
| I1046 | Diled Steel 8.75% notes due 2027 | E1160 |  | E1160 | SU | EUR | no | 2029-06-30 |
| I1047 | Wunam Telecom 5.25% notes due 2032 | E1162 |  | E1162 | SU | EUR | no | 2029-06-30 |
| I1048 | Wenar Water 8.25% notes due 2028 | E1163 |  | E1163 | SUB | EUR | no | 2028-06-30 |
| I1049 | Ranim Shipping 8.00% notes due 2028 | E1166 |  | E1166 | SUB | USD | no | 2036-06-30 |
| I1050 | Fivan Holdings 2.25% notes due 2035 | E1168 |  | E1168 | SU | EUR | no | 2027-06-30 |
| I1051 | Molar Shipping 3.25% notes due 2031 | E1188 |  | E1188 | SU | EUR | no | 2028-06-30 |
| I1052 | Divid Property 4.25% notes due 2033 | E1189 |  | E1189 | SUB | GBP | no | 2032-06-30 |
| I1053 | Piran Logistics 7.25% notes due 2034 | E1190 |  | E1190 | SU | EUR | no | 2028-06-30 |
| I1054 | Lenam Industries 2.50% notes due 2036 | E1195 |  | E1195 | SU | GBP | no | 2030-06-30 |
| I1055 | Kiver Property 8.00% notes due 2032 | E1198 |  | E1198 | SU | EUR | no | 2034-06-30 |
| I1056 | Misam Shipping 8.00% notes due 2036 | E1205 |  | E1205 | SUB | USD | no | 2029-06-30 |
| I1057 | Rival Chemicals 5.25% notes due 2027 | E1206 |  | E1206 | SU | USD | no | 2029-06-30 |
| I1058 | Holar Logistics 5.75% notes due 2030 | E1207 |  | E1207 | SUB | EUR | no | 2029-06-30 |
(56 more rows not shown)

Run more queries, or give the final answers.
The model
Running smaller queries, each returning only a few rows.

```sql
CREATE OR REPLACE TEMP VIEW r AS SELECT DISTINCT rated_id, rating_type, ccy_basis, rating, outlook, watch, action, valid_from, NULLIF(valid_to,'') AS valid_to FROM ratings;
SELECT count(DISTINCT rated_id) AS inst_ig_now FROM r WHERE rating_type='INST' AND valid_to IS NULL AND rating IN ('AAA','AA+','AA','AA-','A+','A','A-','BBB+','BBB','BBB-');
```
```sql
SELECT count(DISTINCT e.entity_id) AS gb_rated FROM entities e JOIN r ON r.rated_id=e.entity_id WHERE e.country='GB' AND r.rating_type='LTIDR' AND r.valid_to IS NULL AND r.rating NOT IN ('WD','NR');
```
```sql
SELECT string_agg(DISTINCT rated_id, ',') AS dg2026 FROM r WHERE rating_type='LTIDR' AND action='DG' AND valid_from BETWEEN '2026-01-01' AND '2026-12-31';
```
```sql
SELECT string_agg(rated_id, ',') AS lost FROM (SELECT rated_id FROM r WHERE rating_type='LTIDR' GROUP BY rated_id HAVING count(*) FILTER (WHERE valid_to IS NULL AND rating NOT IN ('WD','NR'))=0);
```
```sql
SELECT count(*) AS lu FROM entities WHERE country='LU';
```
Query results
Query 1:

| inst_ig_now |
|---|
| 72 |

Query 2:

| gb_rated |
|---|
| 79 |

Query 3:

| dg2026 |
|---|
| E1058,E1167,E5156,E1034,E1285,E1290,E1294,E1151,E1051,E5059,E1160,E10,E1159,E1144,E1243,E5113,E1057,E1053,E5019,E1263,E1229,E1228,E1255,E1298,E1307,E5033,E1080,E5116,E1163,E1213,E1300,E5097,E1112,E08,E1169,E1186,E1064,E1093 |

Query 4:

| lost |
|---|
| E1233,E1320,E1084,E1107,E1041,E1048,E1063,E1277,E1140,E1253,E1308,E1155,E07,E1124,E1062,E1021,E1138,E1032,E1225,E1218,E1205,E1076,E1057,E1172,E1234,E1200,E1206,E1159,E1121,E1166,E1007,E1244,E1001,E1316,E1219 |

Query 5:

| lu |
|---|
| 1 |

Run more queries, or give the final answers.
The model
<invoke name="sql">
</invoke>
```sql
CREATE OR REPLACE TEMP VIEW m AS SELECT entity_id, unnest(string_split(record_ids,' ')) AS rid FROM entities;
CREATE OR REPLACE TEMP VIEW r AS SELECT DISTINCT coalesce(m.entity_id, rated_id) AS eid, rated_id, rating_type, ccy_basis, rating, outlook, watch, action, valid_from, NULLIF(valid_to,'') AS valid_to FROM ratings LEFT JOIN m ON m.rid=ratings.rated_id;
SELECT 'dg2026', string_agg(DISTINCT eid, ',') FROM r WHERE rating_type='LTIDR' AND action='DG' AND valid_from BETWEEN '2026-01-01' AND '2026-12-31'
UNION ALL SELECT 'default_now', string_agg(DISTINCT eid, ',') FROM r WHERE rating IN ('RD','D','SD') AND valid_to IS NULL
UNION ALL SELECT 'default_ever', string_agg(DISTINCT eid, ',') FROM r WHERE rating IN ('RD','D','SD')
UNION ALL SELECT 'rwn_now', string_agg(DISTINCT eid, ',') FROM r WHERE rating_type='LTIDR' AND watch='RWN' AND valid_to IS NULL
UNION ALL SELECT 'neg_now', string_agg(DISTINCT eid, ',') FROM r WHERE rating_type='LTIDR' AND outlook='NEG' AND valid_to IS NULL
UNION ALL SELECT 'issuers_rated_now', count(DISTINCT eid)::varchar FROM r WHERE rating_type='LTIDR' AND valid_to IS NULL AND rating NOT IN ('WD','NR')
UNION ALL SELECT 'gb_rated', count(DISTINCT r.eid)::varchar FROM r JOIN entities e ON e.entity_id=r.eid WHERE e.country='GB' AND rating_type='LTIDR' AND valid_to IS NULL AND rating NOT IN ('WD','NR')
UNION ALL SELECT 'lost', string_agg(eid, ',') FROM (SELECT eid FROM r WHERE rating_type='LTIDR' GROUP BY eid HAVING count(*) FILTER (WHERE valid_to IS NULL AND rating NOT IN ('WD','NR'))=0)
UNION ALL SELECT 'inst_rated_now', count(DISTINCT rated_id)::varchar FROM r WHERE rating_type='INST' AND valid_to IS NULL AND rating NOT IN ('WD','NR')
UNION ALL SELECT 'inst_ig_now', count(DISTINCT rated_id)::varchar FROM r WHERE rating_type='INST' AND valid_to IS NULL AND rating IN ('AAA','AA+','AA','AA-','A+','A','A-','BBB+','BBB','BBB-')
UNION ALL SELECT 'distinct_ratings', string_agg(DISTINCT rating, ',') FROM r
UNION ALL SELECT 'ceil_at', string_agg(eid||':'||e.country||':'||rating, ',') FROM r JOIN entities e ON e.entity_id=r.eid JOIN ceilings c ON c.country=e.country WHERE rating_type='LTIDR' AND ccy_basis='FC' AND valid_to IS NULL AND e.entity_type<>'SOV'
UNION ALL SELECT 'sov', string_agg(rated_id||':'||rating_type||ccy_basis||':'||rating||':'||valid_from||'-'||coalesce(valid_to,''), ' | ') FROM r WHERE rated_id IN ('CV','VD')
UNION ALL SELECT 'nent', count(*)::varchar FROM entities
UNION ALL SELECT 'groups', string_agg(name||'='||entity_id||':'||(SELECT count(*) FROM entities x WHERE x.ultimate_parent_id=e.entity_id)+1, ' ; ') FROM entities e WHERE name IN ('Northwind Holdings plc','Halden Group plc','Cerid Group plc','Rotam Group Inc','Wonod Group SA','Vesol Group BV');
```


<invoke name="sql">
</invoke>
```sql
SELECT 'names', string_agg(entity_id||'='||name||'/'||country||'/'||parent_id||'/'||ultimate_parent_id, ' ; ') FROM entities WHERE name IN ('Cerid Rosor Holdings SA','Cerid Telecom SA','Cerid Guven Energy SA','Belir Mining SA','Rotam Group Inc') 
UNION ALL SELECT 'anc_rosor', string_agg(a.ancestor_id||':'||levels_up, ',') FROM ancestors a JOIN entities e ON e.entity_id=a.entity_id WHERE e.name IN ('Cerid Rosor Holdings SA')
UNION ALL SELECT 'anc_guv_tel', string_agg(e.name||':'||a.ancestor_id||':'||levels_up, ',') FROM ancestors a JOIN entities e ON e.entity_id=a.entity_id WHERE e.name IN ('Cerid Guven Energy SA','Cerid Telecom SA')
UNION ALL SELECT 'guar_outside', string_agg(i.instrument_id||':'||i.guarantor_id||'>'||i.issuer_id||' '||g.ultimate_parent_id||'/'||s.ultimate_parent_id, ' ; ') FROM instruments i JOIN entities g ON g.entity_id=i.guarantor_id JOIN entities s ON s.entity_id=i.issuer_id WHERE i.guarantor_id<>''
UNION ALL SELECT 'cross', string_agg(entity_id||'='||name||'/'||country||'/'||coalesce(ultimate_parent_id,''), ' ; ') FROM entities WHERE entity_id IN ('E5133','E5145')
UNION ALL SELECT 'grp_cnt', string_agg(p.name||':'||(SELECT count(*) FROM entities x WHERE x.ultimate_parent_id=p.entity_id OR x.entity_id=p.entity_id), ' ; ') FROM entities p WHERE name IN ('Northwind Holdings plc','Halden Group plc','Cerid Group plc','Rotam Group Inc','Wonod Group SA','Vesol Group BV')
UNION ALL SELECT 'wonod_vd', string_agg(x.entity_id, ',') FROM entities x JOIN entities p ON p.name='Wonod Group SA' WHERE (x.ultimate_parent_id=p.entity_id OR x.entity_id=p.entity_id) AND x.country='VD'
UNION ALL SELECT 'cerid_l3', count(*)::varchar FROM entities x JOIN entities p ON p.name='Cerid Group plc' JOIN ancestors a ON a.entity_id=x.entity_id AND a.ancestor_id=p.entity_id AND a.levels_up='3'
UNION ALL SELECT 'cerid_hy_fc', string_agg(DISTINCT r.eid||':'||rating, ',') FROM r JOIN entities x ON x.entity_id=r.eid JOIN entities p ON p.name='Cerid Group plc' WHERE (x.ultimate_parent_id=p.entity_id OR x.entity_id=p.entity_id) AND rating_type='LTIDR' AND ccy_basis='FC' AND valid_to IS NULL AND rating NOT IN ('AAA','AA+','AA','AA-','A+','A','A-','BBB+','BBB','BBB-')
UNION ALL SELECT 'vesol_fc', string_agg(DISTINCT r.eid||':'||rating, ',') FROM r JOIN entities x ON x.entity_id=r.eid JOIN entities p ON p.name='Vesol Group BV' WHERE (x.ultimate_parent_id=p.entity_id OR x.entity_id=p.entity_id) AND rating_type='LTIDR' AND ccy_basis='FC' AND valid_to IS NULL
UNION ALL SELECT 'q55', count(DISTINCT r.eid)::varchar FROM r JOIN ancestors a ON a.entity_id=r.eid JOIN entities v ON v.entity_id=a.ancestor_id AND v.country='VD' WHERE rating_type='LTIDR' AND valid_to IS NULL AND rating NOT IN ('WD','NR')
UNION ALL SELECT 'brindle', string_agg(e.entity_id||':'||e.name||':'||coalesce(r.rating||r.valid_from||coalesce(r.valid_to,''),'-'), ' ; ') FROM entities e LEFT JOIN r ON r.eid=e.entity_id WHERE e.name LIKE 'Brindle%' OR e.name LIKE 'Corvenia%'
UNION ALL SELECT 'corv_inst', string_agg(rated_id||':'||rating||':'||valid_from||'-'||coalesce(valid_to,''), ' ; ') FROM r WHERE rated_id IN ('I06','I08','I07','I04','I5007')
UNION ALL SELECT 'orrin', string_agg(rated_id||':'||rating||':'||valid_from||'-'||coalesce(valid_to,''), ' ; ') FROM r WHERE rated_id IN ('E06','E13');
```
Query results
Query 1:

| 'dg2026' | string_agg(DISTINCT eid, ',') |
|---|---|
| dg2026 | E1285,E1290,E1298,E1229,E1307,E1228,E1263,E1255,E5033,E1051,E1294,E1151,E1243,E1159,E1057,E1053,E5019,E5113,E1144,E1034,E1064,E1093,E1300,E1163,E1213,E5097,E1080,E5116,E5156,E1112,E1186,E08,E1169,E1167,E1058,E1160,E10,E5059 |
| default_now | E08 |
| default_ever | E08 |
| rwn_now | E1317,E1037,E1242,E1209,E1013,E1238,E1061,E1297,E1099,E1132,E1260,E1168,E1109,E1039,E1059,E1266,E1126,E1098,E1194,E1088,E1133,E06,E1203,E1146,E1066,E1314,E1323,E1006,E1019,E1264,E1267,E1181 |
| neg_now | E1188,E5057,E1248,E1034,E5019,E5131,E09,E1211,E5113,E1046,E5023,E5062,E5013,E1059,E1056,E1282,E1079,E1005,E1080,E5116,E5039,E1190,E1072,E5156,E1294,E5141,E5119,E1055,E1105,E1158,E1300,E5102,E5097,E1271,E5020,E5059,E1160,E1029,E5033,E1228,E1263,E5099,E5050,E5073,E01,E1064,E1118,E1261 |
| issuers_rated_now | 377 |
| gb_rated | 79 |
| lost | E1063,E1140,E1277,E1233,E1155,E1316,E1244,E1001,E07,E1124,E1205,E1218,E1076,E1308,E1253,E1007,E1121,E1166,E1032,E1225,E1172,E1057,E1200,E1234,E1159,E1206,E1219,E1048,E1107,E1041,E1021,E1062,E1138,E1320,E1084 |
| inst_rated_now | 113 |
| inst_ig_now | 72 |
| distinct_ratings | BB+,A-,BBB-,BB-,AA,A+,BBB+,CCC,B-,BB,F2,AA-,BBB,B,WD,B+,A,RD |
| ceil_at | E1028:VD:BB,E5091:VD:BB,E1126:VD:BB,E1194:CV:A,E5104:CV:BB,E5127:CV:B,E15:CV:A,E1313:VD:BB-,E5098:CV:B-,E1101:VD:BB,E1283:CV:BB,E5012:VD:BB,E1019:CV:BB+,E1096:CV:BBB,E1304:CV:BB,E5116:CV:A,E1071:CV:B+,E1229:CV:BB+,E5117:CV:BB,E1144:CV:B+,E1185:CV:BB+,E1223:CV:BB+,E5023:VD:B-,E1136:CV:A-,E5124:VD:BB,E1106:VD:B+,E1217:CV:BB-,E1243:CV:BB,E1279:VD:WD,E5024:VD:B-,E1039:CV:A,E5106:VD:B-,E5130:VD:B-,E1059:CV:BB-,E1307:VD:BB-,E5047:VD:BB,E05:VD:BB,E1236:VD:BB |
| sov | CV:LTIDRLC:A-:2024-01-01- | CV:LTIDRFC:BBB+:2024-01-01- |
| nent | 497 |
| groups | Northwind Holdings plc=E02:2 ; Halden Group plc=E09:3 ; Cerid Group plc=E5001:58 ; Rotam Group Inc=E5086:19 ; Wonod Group SA=E5105:27 ; Vesol Group BV=E5132:13 |

Query 2:

| 'names' | string_agg(((((((((entity_id || '=') || "name") || '/') || country) || '/') || parent_id) || '/') || ultimate_parent_id), ' ; ') |
|---|---|
| names | E5011=Cerid Guven Energy SA/VD/E5005/E5001 ; E5013=Cerid Telecom SA/ES/E5006/E5001 ; E5047=Cerid Rosor Holdings SA/VD/E5035/E5001 ; E5062=Belir Mining SA/FR/E5060/E5059 |
| anc_rosor | E5035:1,E5023:2,E5011:3,E5005:4,E5002:5,E5001:6 |
| anc_guv_tel | Cerid Guven Energy SA:E5005:1,Cerid Guven Energy SA:E5002:2,Cerid Guven Energy SA:E5001:3,Cerid Telecom SA:E5006:1,Cerid Telecom SA:E5002:2,Cerid Telecom SA:E5001:3 |
| guar_outside | I05:E10>E11 E09/E09 |
| cross | E5133=Vesol Foods plc/GB/E5132 ; E5145=Geren Group SA/VD/ |
| grp_cnt | Northwind Holdings plc:2 ; Halden Group plc:3 ; Cerid Group plc:58 ; Rotam Group Inc:19 ; Wonod Group SA:27 ; Vesol Group BV:13 |
| wonod_vd | E5106,E5124,E5130 |
| cerid_l3 | 12 |
| cerid_hy_fc | E5048:B-,E5010:BB-,E5016:BB,E5037:B+,E5028:B-,E5047:BB,E5013:B-,E5007:B,E5021:B,E5024:B-,E5041:B-,E5030:B,E5023:B-,E5025:BB,E5022:BB-,E5042:BB,E5012:BB,E5039:BB-,E5029:BB+ |
| vesol_fc | E5140:A+,E5133:BBB-,E5141:BB,E5136:BBB-,E5132:BB+,E5143:A,E5144:BB- |
| q55 | 31 |
| brindle | E15:Corvenia Power SA:A+2024-03-01 ; E15:Corvenia Power SA:A2024-03-01 |
| corv_inst | I5007:BBB:2025-02-14- ; I07:BBB-:2025-04-01- ; I06:A-:2024-03-01- ; I04:BB:2025-04-01- |
| orrin | E06:A-:2024-05-01-2026-09-03 ; E06:A-:2026-09-03- ; E13:BBB:2024-07-01- |

Run more queries, or give the final answers.
The model
**Q1.** A-. E01's LTIDR was A- (2024-03-12 to 2025-06-20, A01), covering 1 Jan 2025.
**Q2.** No. E01's only 2026 action was an affirmation on 2026-02-10 (A03, BBB with Negative outlook); the downgrade was in 2025 (A02).
**Q3.** No. The 2031 note (I02) has been rated BB+ since 2025-06-20, which is below investment grade.
**Q4.** Positive. E02's outlook has been POS since 2025-09-15 (A09).
**Q5.** The holder takes the credit risk of E02, Northwind Holdings, the guarantor of I03 (issued by E04). E02 is rated A, and I03 itself is rated A.
**Q6.** The data does not state a reason. Valdoria's ceiling is BB (from 2025-04-01), and E05's FC rating is BB against an LC rating of BBB- (A14, A13), which is consistent with a ceiling cap.
**Q7.** Downgraded in 2026 (DG actions on LTIDR; includes E08, E10 and the other entities in the JSON): 38 entities, listed in the JSON.
**Q8.** E08. Saxby Shipping has been RD since 2026-07-08 (A22).
**Q9.** 377 distinct entities held an LTIDR (excluding withdrawn) on 1 Oct 2026.
**Q10.** Depends. E05 is BB on foreign currency (non-IG) but BBB- on local currency (IG).
**Q11.** BBB+. E14 held BBB+ from 2024-09-30 to 2025-11-20 (A36).
**Q12.** A-. E14 held A- from 2023-01-15 to 2024-09-30 (A34).
**Q13.** 1. The only downgrade was A- to BBB+ on 2024-09-30 (A36).
**Q14.** None. E12's first rating began 2024-02-01 (A30).
**Q15.** A-. E10 held A- until 2026-04-15 (A26).
**Q16.** No. E14 was BBB+ on 1 Jan 2025 and is BBB+ now; only the watch status changed in between (A35, A33).
**Q17.** No. E06's 2026 action was a Rating Watch Negative placement at A- on 2026-09-03 (A17), not a downgrade.
**Q18.** 32 entities were on Rating Watch Negative (RWN) on 1 Oct 2026, listed in the JSON, including E06 (A17). The list includes E1019, whose RWN is on its LC rating only.
**Q19.** 48 entities had a Negative outlook, listed in the JSON (includes E01, A03).
**Q20.** No. E07's rating was withdrawn on 2026-05-12 (A19); no default rating exists.
**Q21.** 35 entities had a rating that was later withdrawn, with no rating in force on 1 Oct 2026 (includes E07, E1001), listed in the JSON.
**Q22.** E08 is the only entity with an RD rating (A22).
**Q23.** F2. This is E01's STIDR (A04).
**Q24.** Yes. E01's issuer rating is BBB.
**Q25.** 72 instruments held an investment-grade (BBB- or above) rating.
**Q26.** A+. This is E15's LC LTIDR (A40).
**Q27.** A-. I06 has been rated A- since 2024-03-01 (A42).
**Q28.** BBB+. This is CV's FC LTIDR.
**Q29.** None. The data holds no rating for VD.
**Q30.** 13 entities sit exactly at their ceiling: CV (A) E1194, E15, E5116, E1039; VD (BB) E1028, E5091, E1126, E1101, E5012, E5124, E5047, E1236, E05.
**Q31.** No. No FC issuer rating exceeds its ceiling (CV A, VD BB).
**Q32.** E09. E11's parent is E10, whose parent is E09.
**Q33.** The holder takes the risk of E10, Halden Bank, the guarantor of I05. E10 is rated BBB+ (A27), as is I05 (A29).
**Q34.** No. E12 has no parent, so it is outside the E09 group that contains E10.
**Q35.** 3 (E09, E10, E11).
**Q36.** 2 (E02, E04).
**Q37.** 497 entities, with duplicate records already merged.
**Q38.** No. E06 and E13 are separate entities with different LEIs and countries.
**Q39.** A. This is E02's current LTIDR.
**Q40.** 79.
**Q41.** None. No entity named Brindle Capital exists in the data.
**Q42.** LU. E10 is domiciled there.
**Q43.** 1.
**Q44.** Yes. I07 is in XVD with local_currency = yes.
**Q45.** No. The ceiling constrains foreign-currency ratings, and I07 is a local-currency obligation (BBB-).
**Q46.** No. E11 has no LTIDR record.
**Q47.** None. I08 has no rating record.
**Q48.** 113.
**Q49.** E5001. The ancestors table shows E5001 at 6 levels up from E5047.
**Q50.** 6.
**Q51.** 58.
**Q52.** 19.
**Q53.** No. E5062 sits under E5059, while Rotam Group Inc (E5086) is a separate group top.
**Q54.** E5106, E5124, E5130.
**Q55.** 31.
**Q56.** BB-. This is E5144, the lowest current FC LTIDR in the Vesol group.
**Q57.** E5002. Both entities have it as a parent 2 levels up.
**Q58.** E5145 guarantees I5007, issued by E5133 in the Vesol group, while E5145 has no group parent. The only other guaranteed notes, I05 and I03, are guaranteed within the group.
**Q59.** 12.
**Q60.** The holder takes the risk of E5145, Geren Group SA. It is not in the same group as the issuer E5133, which sits under E5132.
**Q61.** 19.

```json
{
"Q1":{"rating":"A-"},
"Q2":{"downgraded":"no"},
"Q3":{"investment_grade":"no","rating":"BB+"},
"Q4":{"outlook":"POS"},
"Q5":{"risk_of":"E02","rating":"A"},
"Q7":{"issuers":["E1285","E1290","E1298","E1229","E1307","E1228","E1263","E1255","E5033","E1051","E1294","E1151","E1243","E1159","E1057","E1053","E5019","E5113","E1144","E1034","E1064","E1093","E1300","E1163","E1213","E5097","E1080","E5116","E5156","E1112","E1186","E08","E1169","E1167","E1058","E1160","E10","E5059"]},
"Q8":{"entities":["E08"]},
"Q9":{"count":377},
"Q10":{"investment_grade":"depends"},
"Q11":{"rating":"BBB+"},
"Q12":{"rating":"A-"},
"Q13":{"count":1},
"Q14":{"rating":"none"},
"Q15":{"rating":"A-"},
"Q16":{"changed":"no"},
"Q17":{"downgraded":"no"},
"Q18":{"issuers":["E1317","E1037","E1242","E1209","E1013","E1238","E1061","E1297","E1099","E1132","E1260","E1168","E1109","E1039","E1059","E1266","E1126","E1098","E1194","E1088","E1133","E06","E1203","E1146","E1066","E1314","E1323","E1006","E1019","E1264","E1267","E1181"]},
"Q19":{"issuers":["E1188","E5057","E1248","E1034","E5019","E5131","E09","E1211","E5113","E1046","E5023","E5062","E5013","E1059","E1056","E1282","E1079","E1005","E1080","E5116","E5039","E1190","E1072","E5156","E1294","E5141","E5119","E1055","E1105","E1158","E1300","E5102","E5097","E1271","E5020","E5059","E1160","E1029","E5033","E1228","E1263","E5099","E5050","E5073","E01","E1064","E1118","E1261"]},
"Q20":{"in_default":"no"},
"Q21":{"entities":["E1063","E1140","E1277","E1233","E1155","E1316","E1244","E1001","E07","E1124","E1205","E1218","E1076","E1308","E1253","E1007","E1121","E1166","E1032","E1225","E1172","E1057","E1200","E1234","E1159","E1206","E1219","E1048","E1107","E1041","E1021","E1062","E1138","E1320","E1084"]},
"Q22":{"entities":["E08"]},
"Q23":{"rating":"F2"},
"Q24":{"investment_grade":"yes"},
"Q25":{"count":72},
"Q26":{"rating":"A+"},
"Q27":{"rating":"A-"},
"Q28":{"rating":"BBB+"},
"Q29":{"rating":"none"},
"Q30":{"entities":["E1194","E15","E5116","E1039","E1028","E5091","E1126","E1101","E5012","E5124","E5047","E1236","E05"]},
"Q31":{"any":"no"},
"Q32":{"parent":"E09"},
"Q33":{"risk_of":"E10","rating":"BBB+"},
"Q34":{"same_group":"no"},
"Q35":{"count":3},
"Q36":{"count":2},
"Q37":{"count":497},
"Q38":{"same":"no"},
"Q39":{"rating":"A"},
"Q40":{"count":79},
"Q41":{"rating":"none"},
"Q42":{"country":"LU"},
"Q43":{"count":1},
"Q44":{"local_currency":"yes"},
"Q45":{"above_ceiling":"no"},
"Q46":{"issuer_rating":"no"},
"Q47":{"rating":"none"},
"Q48":{"count":113},
"Q49":{"parent":"E5001"},
"Q50":{"count":6},
"Q51":{"count":58},
"Q52":{"count":19},
"Q53":{"same_group":"no"},
"Q54":{"entities":["E5106","E5124","E5130"]},
"Q55":{"count":31},
"Q56":{"rating":"BB-"},
"Q57":{"entity":"E5002"},
"Q58":{"entities":["E5145"]},
"Q59":{"count":12},
"Q60":{"risk_of":"E5145","same_group":"no"},
"Q61":{"count":19}
}
```