D3 sql+executed, run 2: the query session

← back to the run

11 queries0 failed6 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 structure.

```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 '%Wonod%' OR name ILIKE '%Vesol%' OR name ILIKE '%Belir%' 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
<invoke name="sql">
</invoke>
```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 IN ('E01','E02','E03','E04','E05','E06','E07','E08','E09','E10','E11','E12','E13','E14','E15','E16','E17','E18','E19','E20','I01','I02','I03','I04','I05','I06','I07','I08','I5007') ORDER BY rated_id, rating_type, ccy_basis, valid_from;
```
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 |
| E1001 | Tunod Steel SA | 3912003R00FP6CNV6210 | FR | CORP |  |  | E1001 E1002 |
| E1003 | Rilol Telecom plc | 3912009W4J483WB8PZ97 | GB | BANK |  |  | E1003 |
| E1004 | Munem Retail SA | 969500IBYK0X2ZT52780 | ES | CORP |  |  | E1004 |
| E1005 | Setan Airlines Inc | 815600JRN7AOE36KFR35 | US | CORP |  |  | E1005 |
| E1006 | Soson Airlines Inc | 213800WSVEOAQ5HD4C43 | US | CORP | E1005 | E1005 | E1006 |
| E1007 | Golod Property plc | 815600N2UAHQREHHWF76 | GB | BANK |  |  | E1007 |
| E1008 | Sotil Retail plc | 213800RPNJ2OSQ387M40 | GB | CORP |  |  | E1008 |
| E1009 | Malam Chemicals Inc | 3912006EIY6TU9NVSC86 | US | CORP |  |  | E1009 |
| E1010 | Buvir Industries Inc | 3912004R2GZJL49URX69 | US | CORP |  |  | E1010 |
| E1011 | Falom Media Inc | 549300XX6U9N4Y7KPH74 | US | BANK |  |  | E1011 |
| E1012 | Posad Industries SA | 9695002JIQI5QYDN0G98 | FR | CORP |  |  | E1012 |
| E1013 | Pisol Pharma BV | 969500U072SAPPW32N81 | NL | BANK | E1004 | E1004 | E1013 |
| E1014 | Toral Utilities BV | 391200J700D8T2H18W16 | NL | CORP |  |  | E1014 |
| E1015 | Civen Steel Inc | 815600JSNIJ4UFCBF662 | US | CORP |  |  | E1015 |
| E1016 | Ponar Telecom SA | 5493008DQ96XI37KZG24 | ES | BANK |  |  | E1016 |
| E1017 | Nisid Steel SA | 391200K600X7LWZTTM85 | FR | BANK |  |  | E1017 |
| E1018 | Tosem Mining Inc | 549300SEMGL6OXLWHQ59 | US | CORP |  |  | E1018 |
| E1019 | Losol Mining SA | 391200GSFO0F68KKUC67 | CV | CORP |  |  | E1019 |
| E1020 | Finel Media AG | 549300FCSHHELSCZX562 | DE | CORP |  |  | E1020 |
| E1021 | Niner Pharma plc | 391200KLG6G4KVIMIU52 | GB | CORP |  |  | E1021 E1022 |
| E1023 | Heled Water plc | 3912006FHXTH5V6WNK07 | GB | CORP |  |  | E1023 |
| E1024 | Susin Shipping BV | 3912005J04HB7X0GTN24 | NL | CORP |  |  | E1024 |
| E1025 | Tulol Shipping SA | 2138007MIV2OS05PET94 | ES | BANK |  |  | E1025 |
| E1026 | Vunam Water BV | 969500C8XYHXZBFMUO41 | NL | CORP |  |  | E1026 |
| E1027 | Tesad Media Inc | 969500T86HNH5S920X18 | US | CORP |  |  | E1027 |
| E1028 | Mutir Retail SA | 213800TJ32NARU0BI982 | VD | CORP |  |  | E1028 |
| E1029 | Leson Telecom Inc | 8156008DPX4I9DNKWN26 | US | BANK |  |  | E1029 E1030 |
| E1031 | Kuvir Logistics SA | 969500GRHP48SQNEWH44 | ES | CORP |  |  | E1031 |
| E1032 | Helom Chemicals BV | 2138006H9XCYN2P1K228 | NL | BANK |  |  | E1032 |
| E1033 | Kunid Pharma SA | 213800Q84PS4FTJJB947 | ES | CORP | E1004 | E1004 | E1033 |
| E1034 | Tanad Capital SpA | 815600KLV84WAQGPSX27 | IT | CORP |  |  | E1034 |
| E1035 | Kavod Utilities AG | 724500YHN51API4SE179 | DE | CORP |  |  | E1035 |
| E1036 | Lilor Retail AG | 9695000N72OQ0Q07IW61 | DE | CORP |  |  | E1036 |
| E1037 | Natil Retail SA | 391200OBAXI8590VQN12 | FR | CORP |  |  | E1037 |
| E1038 | Lanon Telecom BV | 549300EZ4HXP0L5RAZ01 | NL | CORP |  |  | E1038 |
| E1039 | Pulor Airlines SA | 969500HA9D5I7F73PW83 | CV | BANK |  |  | E1039 |
| E1040 | Dorid Mining AG | 549300SPMD9MEMFWMR12 | DE | CORP |  |  | E1040 |
| E1041 | Hiral Steel SA | 549300JU1O5MP1HSKQ01 | ES | CORP |  |  | E1041 |
| E1042 | Rerod Steel BV | 391200LC6V921W096L49 | NL | CORP |  |  | E1042 |
| E1043 | Vitom Property plc | 5493007IVTPIWJZLFF29 | GB | CORP |  |  | E1043 |
| E1044 | Hesid Telecom Inc | 3912003Y7VZHUGN50755 | US | BANK |  |  | E1044 |
| E1045 | Nesid Logistics Inc | 96950029VB162U3K1976 | US | BANK |  |  | E1045 |
| E1046 | Ditin Shipping Inc | 549300ZM08IADSAK3L87 | US | BANK | E1026 | E1026 | E1046 |
| E1047 | Vaved Pharma plc | 391200WGA8OE30KZUD08 | GB | CORP | E1020 | E1020 | E1047 |
| E1048 | Lised Pharma AG | 9695000T21G05UQMGF10 | DE | CORP |  |  | E1048 |
| E1049 | Paser Utilities plc | 391200R2EH7FELZFOV27 | GB | CORP |  |  | E1049 |
| E1050 | Sunar Holdings AG | 969500YF1ZXQV9ONT388 | DE | CORP |  |  | E1050 |
| E1051 | Kenar Water SA | 724500WO4TZY2027IZ62 | GR | CORP |  |  | E1051 |
| E1052 | Witad Steel SA | 213800ENVP6736MREW83 | FR | CORP |  |  | E1052 |
| E1053 | Soter Water SA | 5493001E7O9QDD98PV36 | ES | CORP |  |  | E1053 |
(271 more rows not shown)

Query 2:

| 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 |
| 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 |
| 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 |
| I5007 | INST |  | BBB |  |  | AS | 2025-02-14 |  | A5126 |

Run more queries, or give the final answers.
The model
```sql
SELECT * FROM entities WHERE entity_id IN ('E11','E12','E13','E14','E15','E16','E17','E18','E19','E20','CV') OR name ILIKE '%Marlow%' OR name ILIKE '%Brindle%' OR name ILIKE '%Orrin%' OR name ILIKE '%Wonod%' OR name ILIKE '%Vesol%' OR name ILIKE '%Rotam%' OR name ILIKE '%Cerid Rosor%' OR name ILIKE '%Cerid Telecom%' OR name ILIKE '%Halden%' ORDER BY entity_id;
```
```sql
SELECT * FROM ratings WHERE rated_id='CV' OR rated_id IN ('E16','E17','E18','E19','E20','E11') ORDER BY rated_id, valid_from;
```
```sql
SELECT country, count(*) FROM entities WHERE country IN ('LU') GROUP BY 1;
```
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 |
| E06 | Orrin Bank AG | 549300AMVE3VRVG7HK43 | DE | BANK |  |  | E06 |
| 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 |
| E5013 | Cerid Telecom SA | 724500EU84AMOZS7U244 | ES | BANK | E5006 | E5001 | E5013 |
| E5047 | Cerid Rosor Holdings SA | 8156004CDHFBVRR3LT54 | VD | BANK | E5035 | E5001 | E5047 |
| E5086 | Rotam Group Inc | 213800PJV1XFQEKJ1L86 | US | CORP |  |  | E5086 |
| E5087 | Rotam Mining Inc | 724500OT1LFBVAVBRI55 | US | CORP | E5086 | E5086 | E5087 |
| E5088 | Rotam Industries Inc | 72450088A4BIGJ0A1N08 | US | CORP | E5086 | E5086 | E5088 |
| E5089 | Rotam Airlines Inc | 7245008N6U91AB1U1398 | US | CORP | E5086 | E5086 | E5089 |
| E5090 | Rotam Logistics Inc | 724500J7FCE6HMEBB653 | US | CORP | E5087 | E5086 | E5090 |
| E5091 | Rotam Water SA | 7245007V26QZ8EY8MZ45 | VD | CORP | E5088 | E5086 | E5091 |
| E5092 | Rotam Hison Holdings Inc | 391200GBH7B6XVDLYP36 | US | CORP | E5089 | E5086 | E5092 |
| E5093 | Rotam Telecom Inc | 391200SIBITK6V9AYU16 | US | CORP | E5090 | E5086 | E5093 |
| E5094 | Rotam Holdings Inc | 72450096SJSRDS8ZI255 | US | CORP | E5090 | E5086 | E5094 |
| E5095 | Rotam Energy BV | 815600HA1HK1TIMKR785 | NL | BANK | E5091 | E5086 | E5095 |
| E5096 | Rotam Lulel Mining SA | 549300CUU7XMKSLTTB66 | ES | BANK | E5091 | E5086 | E5096 |
| E5097 | Rotam Chemicals Inc | 3912008BZ54JQ8UNFG51 | US | BANK | E5092 | E5086 | E5097 |
| E5098 | Rotam Pharma SA | 815600LW5B06S1CQW672 | CV | CORP | E5092 | E5086 | E5098 |
| E5099 | Rotam Fived Water Inc | 815600UU6JEHIIMLC927 | US | CORP | E5093 | E5086 | E5099 |
| E5100 | Rotam Property Inc | 724500GA08KIJSPLUI93 | US | BANK | E5094 | E5086 | E5100 |
| E5101 | Rotam Foods BV | 724500VSL9A06KR45I76 | NL | CORP | E5095 | E5086 | E5101 |
| E5102 | Rotam Utilities SA | 96950092DKV427KADB93 | ES | CORP | E5096 | E5086 | E5102 |
| E5103 | Rotam Goson Energy Inc | 724500LIPSS64F2BVY06 | US | CORP | E5097 | E5086 | E5103 |
| E5104 | Rotam Media SA | 724500JZITB0L2T1PH98 | CV | CORP | E5098 | E5086 | E5104 |
| E5105 | Wonod Group SA | 7245003GC3MAPLM74H56 | FR | CORP |  |  | E5105 |
| E5106 | Wonod Steel BV | 969500W1342GHBTOGH81 | VD | CORP | E5105 | E5105 | E5106 E5169 |
| E5107 | Wonod Retail BV | 21380092E5EHPJ4TFV08 | NL | CORP | E5105 | E5105 | E5107 |
| E5108 | Wonod Shipping BV | 969500GFVXV2N0QJJ192 | NL | CORP | E5106 | E5105 | E5108 |
| E5109 | Wonod Holdings SA | 815600AHGVOU0SPTG094 | FR | CORP | E5106 | E5105 | E5109 |
| E5110 | Wonod Capital BV | 9695006QN6F7HCKCUF24 | NL | CORP | E5106 | E5105 | E5110 |
| E5111 | Wonod Airlines SA | 8156007JSKV2AQVXO923 | CV | CORP | E5107 | E5105 | E5111 |
| E5112 | Wonod Telecom BV | 213800RG52C0JR6AJF65 | NL | CORP | E5107 | E5105 | E5112 |
| E5113 | Wonod Wetid Foods BV | 391200F077WCSDTMTP77 | NL | CORP | E5107 | E5105 | E5113 |
| E5114 | Wonod Pharma Inc | 7245005SRMAA70J2TD65 | US | CORP | E5108 | E5105 | E5114 |
| E5115 | Wonod Water SA | 969500R5VDDM7EGRNE68 | FR | CORP | E5109 | E5105 | E5115 |
| E5116 | Wonod Media SA | 724500I4E8HLVDTIKT27 | CV | CORP | E5110 | E5105 | E5116 |
| E5117 | Wonod Mining SA | 815600S1Y8PRQ014AM59 | CV | CORP | E5111 | E5105 | E5117 |
| E5118 | Wonod Wevan Logistics BV | 815600KWD2K0VOPED085 | NL | CORP | E5112 | E5105 | E5118 |
| E5119 | Wonod Povem Telecom SA | 391200SY8W07WDP69G34 | FR | CORP | E5113 | E5105 | E5119 |
| E5120 | Wonod Property Inc | 81560040PS8E00LR6M78 | US | BANK | E5114 | E5105 | E5120 |
| E5121 | Wonod Energy SA | 549300UCYMMVP94NQX38 | FR | CORP | E5115 | E5105 | E5121 |
| E5122 | Wonod Chemicals SA | 81560047EAYEL7V8VI20 | FR | CORP | E5116 | E5105 | E5122 |
| E5123 | Wonod Utilities SA | 549300RUQWG4VIV5KY48 | ES | BANK | E5117 | E5105 | E5123 |
| E5124 | Wonod Kinon Holdings SA | 213800CPQNCG46SCSV94 | VD | CORP | E5118 | E5105 | E5124 |
| E5125 | Wonod Koval Capital SA | 549300I028ICLWFHUK31 | FR | CORP | E5119 | E5105 | E5125 |
| E5126 | Wonod Tetim Holdings Inc | 391200TDW0CDEAOZ0B63 | US | CORP | E5120 | E5105 | E5126 |
| E5127 | Wonod Pavad Media SA | 8156005BP06D67UX1Z45 | CV | CORP | E5121 | E5105 | E5127 |
| E5128 | Wonod Horal Steel SA | 72450003RPAMWMQANJ28 | FR | BANK | E5122 | E5105 | E5128 |
| E5129 | Wonod Logistics SA | 391200UAVGFU3T7SBV10 | ES | BANK | E5123 | E5105 | E5129 |
| E5130 | Wonod Huror Retail SA | 391200WLN00ZH5R20305 | VD | CORP | E5124 | E5105 | E5130 |
| E5131 | Wonod Bunem Industries SA | 724500S6MKGNUW1YNO80 | ES | CORP | E5125 | E5105 | E5131 |
| E5132 | Vesol Group BV | 724500QJUUI5LKTI3C20 | NL | CORP |  |  | E5132 |
| E5133 | Vesol Foods plc | 969500J32JMVAGT5XX78 | GB | BANK | E5132 | E5132 | E5133 |
| E5134 | Vesol Steel BV | 213800V5SY9HVVH89I73 | NL | CORP | E5132 | E5132 | E5134 |
(10 more rows not shown)

Query 2:

| rated_id | rating_type | ccy_basis | rating | outlook | watch | action | valid_from | valid_to | action_id |
|---|---|---|---|---|---|---|---|---|---|
| CV | LTIDR | FC | BBB+ | STA |  | AS | 2024-01-01 |  | A38 |
| CV | LTIDR | LC | A- | STA |  | AS | 2024-01-01 |  | A39 |

Query 3:

| country | count_star() |
|---|---|
| LU | 1 |

Run more queries, or give the final answers.
The model
```sql
SELECT 'Q9' q, count(DISTINCT rated_id)::VARCHAR v FROM ratings WHERE rating_type='LTIDR' AND ccy_basis='FC' AND (valid_to IS NULL OR valid_to='') AND rating<>'WD'
UNION ALL SELECT 'Q18', string_agg(DISTINCT rated_id, ',') FROM ratings WHERE watch='RWN' AND (valid_to IS NULL OR valid_to='')
UNION ALL SELECT 'Q19', string_agg(DISTINCT rated_id, ',') FROM ratings WHERE outlook='NEG' AND (valid_to IS NULL OR valid_to='')
UNION ALL SELECT 'Q8', string_agg(DISTINCT rated_id, ',') FROM ratings WHERE rating IN ('RD','D') AND (valid_to IS NULL OR valid_to='')
UNION ALL SELECT 'Q22', string_agg(DISTINCT rated_id, ',') FROM ratings WHERE rating IN ('RD','D')
UNION ALL SELECT 'Q21', string_agg(DISTINCT rated_id, ',') FROM ratings r WHERE rating_type='LTIDR' AND ccy_basis='FC' AND rated_id NOT IN (SELECT rated_id FROM ratings WHERE rating_type='LTIDR' AND ccy_basis='FC' AND (valid_to IS NULL OR valid_to='') AND rating<>'WD')
UNION ALL SELECT 'Q17', string_agg(DISTINCT rated_id, ',') FROM ratings WHERE action='DG' AND valid_from>='2026-01-01' AND rating_type='LTIDR';
```
Query results
Query 1:

| q | v |
|---|---|
| Q9 | 376 |
| Q18 | E1013,E1061,E1238,E1297,E1109,E1168,E1099,E1132,E1260,E1006,E1019,E1264,E06,E1133,E1088,E1194,E1066,E1146,E1203,E1314,E1323,E1037,E1209,E1242,E1317,E1181,E1098,E1126,E1267,E1039,E1059,E1266 |
| Q19 | E1005,E1080,E5116,E1105,E1158,E1046,E1055,E1294,E5119,E5141,E1034,E1188,E1248,E5057,E1079,E1056,E1059,E1282,E5013,E5023,E5062,E1300,E5097,E5102,E1072,E1190,E5039,E5156,E01,E1064,E1118,E1261,E09,E1211,E5019,E5113,E5131,E1029,E1160,E5020,E5059,E1271,E1228,E1263,E5033,E5050,E5073,E5099 |
| Q8 | E08 |
| Q22 | E08 |
| Q21 | E1007,E1032,E1057,E1155,E1159,E1253,E1308,E1121,E1205,E1206,E1219,E1320,E1244,E1316,E1062,E1277,E1218,E07,E1021,E1166,E1279,E1001,E1124,E1172,E1048,E1084,E1041,E1063,E1107,E1138,E1140,E1200,E1225,E1233,E1234,E1076 |
| Q17 | E1285,E1290,E1058,E1167,E08,E1112,E1169,E1186,E1053,E1057,E1144,E1159,E1243,E5019,E5113,E1064,E1093,E1080,E5116,E1151,E1294,E1051,E1163,E1213,E1300,E5097,E10,E1160,E5059,E1034,E1228,E1229,E1255,E1263,E1298,E1307,E5033,E5156 |

Run more queries, or give the final answers.
The model
```sql
SELECT 'Q9cv' q, string_agg(DISTINCT rated_id, ',') v FROM ratings WHERE rated_id IN ('CV') AND (valid_to IS NULL OR valid_to='')
UNION ALL SELECT 'Q41', string_agg(entity_id||':'||name||':'||country, ';') FROM entities WHERE name ILIKE '%Brindle%'
UNION ALL SELECT 'Q29', string_agg(entity_id||':'||name, ';') FROM entities WHERE entity_type='SOV' OR name ILIKE '%Republic%'
UNION ALL SELECT 'Q25', count(DISTINCT rated_id)::VARCHAR FROM ratings WHERE rating_type='INST' AND (valid_to IS NULL OR valid_to='') AND rating IN ('AAA','AA+','AA','AA-','A+','A','A-','BBB+','BBB','BBB-')
UNION ALL SELECT 'Q48', count(DISTINCT rated_id)::VARCHAR FROM ratings WHERE rating_type='INST' AND (valid_to IS NULL OR valid_to='') AND rating NOT IN ('WD')
UNION ALL SELECT 'Q40', count(DISTINCT r.rated_id)::VARCHAR FROM ratings r JOIN entities e ON e.entity_id=r.rated_id WHERE e.country='GB' AND r.rating_type='LTIDR' AND r.ccy_basis='FC' AND (valid_to IS NULL OR valid_to='') AND r.rating<>'WD'
UNION ALL SELECT 'Q30', string_agg(r.rated_id||':'||r.rating, ',') FROM ratings r JOIN entities e ON e.entity_id=r.rated_id JOIN ceilings c ON c.country=e.country WHERE r.rating_type='LTIDR' AND r.ccy_basis='FC' AND (r.valid_to IS NULL OR r.valid_to='') AND e.entity_type<>'SOV'
UNION ALL SELECT 'Q35', string_agg(entity_id,',') FROM entities WHERE entity_id='E09' OR ultimate_parent_id='E09'
UNION ALL SELECT 'Q36', string_agg(entity_id,',') FROM entities WHERE entity_id='E02' OR ultimate_parent_id='E02'
UNION ALL SELECT 'Q51', count(*)::VARCHAR FROM entities WHERE entity_id='E5001' OR ultimate_parent_id='E5001'
UNION ALL SELECT 'Q52', count(*)::VARCHAR FROM entities WHERE entity_id='E5086' OR ultimate_parent_id='E5086'
UNION ALL SELECT 'Q50', string_agg(ancestor_id||':'||levels_up, ',') FROM ancestors WHERE entity_id='E5047'
UNION ALL SELECT 'Q54', string_agg(entity_id,',') FROM entities WHERE (entity_id='E5105' OR ultimate_parent_id='E5105') AND country='VD'
UNION ALL SELECT 'Q57', string_agg(a.ancestor_id||':'||a.levels_up||'/'||b.levels_up, ',') FROM ancestors a JOIN ancestors b ON a.ancestor_id=b.ancestor_id WHERE a.entity_id='E5011' AND b.entity_id='E5013'
UNION ALL SELECT 'Q59', count(*)::VARCHAR FROM ancestors WHERE ancestor_id='E5001' AND levels_up=3
UNION ALL SELECT 'Q55', count(DISTINCT r.rated_id)::VARCHAR FROM ratings r JOIN ancestors a ON a.entity_id=r.rated_id JOIN entities e ON e.entity_id=a.ancestor_id WHERE e.country='VD' AND r.rating_type='LTIDR' AND r.ccy_basis='FC' AND (r.valid_to IS NULL OR r.valid_to='') AND r.rating<>'WD'
UNION ALL SELECT 'Q56', string_agg(r.rated_id||':'||r.rating, ',') FROM ratings r JOIN entities e ON e.entity_id=r.rated_id WHERE (e.entity_id='E5132' OR e.ultimate_parent_id='E5132') AND r.rating_type='LTIDR' AND r.ccy_basis='FC' AND (r.valid_to IS NULL OR r.valid_to='')
UNION ALL SELECT 'Q61', string_agg(r.rated_id||':'||r.rating, ',') FROM ratings r JOIN entities e ON e.entity_id=r.rated_id WHERE (e.entity_id='E5001' OR e.ultimate_parent_id='E5001') AND r.rating_type='LTIDR' AND r.ccy_basis='FC' AND (r.valid_to IS NULL OR r.valid_to='') AND r.rating NOT IN ('AAA','AA+','AA','AA-','A+','A','A-','BBB+','BBB','BBB-','WD')
UNION ALL SELECT 'Q58', string_agg(i.instrument_id||':'||i.issuer_id||'>'||i.guarantor_id, ',') FROM instruments i JOIN entities a ON a.entity_id=i.issuer_id JOIN entities g ON g.entity_id=i.guarantor_id WHERE i.guarantor_id<>'' AND coalesce(nullif(a.ultimate_parent_id,''),a.entity_id)<>coalesce(nullif(g.ultimate_parent_id,''),g.entity_id)
UNION ALL SELECT 'Q60', string_agg(entity_id||':'||name||':'||coalesce(ultimate_parent_id,''), ',') FROM entities WHERE entity_id IN ('E5145','E5133');
```
Query results
Query 1:

| q | v |
|---|---|
| Q9cv | CV |
| Q41 |  |
| Q29 | CV:Republic of Corvenia;VD:Republic of Valdoria |
| Q25 | 72 |
| Q48 | 113 |
| Q40 | 79 |
| Q30 | E05:BB,E15:A,E1019:BB+,E1028:BB,E1039:A,E1059:BB-,E1071:B+,E1096:BBB,E1101:BB,E1106:B+,E1126:BB,E1136:A-,E1144:B+,E1185:BB+,E1194:A,E1217:BB-,E1223:BB+,E1229:BB+,E1236:BB,E1243:BB,E1279:WD,E1283:BB,E1304:BB,E1307:BB-,E1313:BB-,E5012:BB,E5023:B-,E5024:B-,E5047:BB,E5091:BB,E5098:B-,E5104:BB,E5106:B-,E5116:A,E5117:BB,E5124:BB,E5127:B,E5130:B- |
| Q35 | E09,E10,E11 |
| Q36 | E02,E04 |
| Q51 | 58 |
| Q52 | 19 |
| Q50 | E5035:1,E5023:2,E5011:3,E5005:4,E5002:5,E5001:6 |
| Q54 | E5106,E5124,E5130 |
| Q57 | E5002:2/2,E5001:3/3 |
| Q59 | 12 |
| Q55 | 31 |
| Q56 | E5132:BB+,E5133:BBB-,E5136:BBB-,E5140:A+,E5141:BB,E5143:A,E5144:BB- |
| Q61 | E5007:B,E5010:BB-,E5012:BB,E5013:B-,E5016:BB,E5021:B,E5022:BB-,E5023:B-,E5024:B-,E5025:BB,E5028:B-,E5029:BB+,E5030:B,E5037:B+,E5039:BB-,E5041:B-,E5042:BB,E5047:BB,E5048:B- |
| Q58 | I5007:E5133>E5145 |
| Q60 | E5133:Vesol Foods plc:E5132,E5145:Geren Group SA: |

Run more queries, or give the final answers.
The model
<invoke name="sql">
</invoke>
```sql
SELECT 'VD' k, string_agg(rated_id||':'||rating||':'||valid_from||':'||coalesce(valid_to,''),';') v FROM ratings WHERE rated_id='VD'
UNION ALL
SELECT 'ceil', string_agg(r.rated_id||':'||e.country||':'||e.entity_type||':'||r.rating||':'||c.ceiling, ',') FROM ratings r JOIN entities e ON e.entity_id=r.rated_id JOIN ceilings c ON c.country=e.country WHERE r.rating_type='LTIDR' AND r.ccy_basis='FC' AND (r.valid_to IS NULL OR r.valid_to='') AND e.entity_type<>'SOV' AND r.rating<>'WD';
```
Query results
Query 1:

| k | v |
|---|---|
| VD |  |
| ceil | E05:VD:CORP:BB:BB,E15:CV:CORP:A:A,E1019:CV:CORP:BB+:A,E1028:VD:CORP:BB:BB,E1039:CV:BANK:A:A,E1059:CV:CORP:BB-:A,E1071:CV:CORP:B+:A,E1096:CV:CORP:BBB:A,E1101:VD:CORP:BB:BB,E1106:VD:BANK:B+:BB,E1126:VD:BANK:BB:BB,E1136:CV:CORP:A-:A,E1144:CV:CORP:B+:A,E1185:CV:CORP:BB+:A,E1194:CV:CORP:A:A,E1217:CV:CORP:BB-:A,E1223:CV:CORP:BB+:A,E1229:CV:BANK:BB+:A,E1236:VD:BANK:BB:BB,E1243:CV:BANK:BB:A,E1283:CV:CORP:BB:A,E1304:CV:CORP:BB:A,E1307:VD:CORP:BB-:BB,E1313:VD:BANK:BB-:BB,E5012:VD:CORP:BB:BB,E5023:VD:CORP:B-:BB,E5024:VD:CORP:B-:BB,E5047:VD:BANK:BB:BB,E5091:VD:CORP:BB:BB,E5098:CV:CORP:B-:A,E5104:CV:CORP:BB:A,E5106:VD:CORP:B-:BB,E5116:CV:CORP:A:A,E5117:CV:CORP:BB:A,E5124:VD:CORP:BB:BB,E5127:CV:CORP:B:A,E5130:VD:CORP:B-:BB |

Run more queries, or give the final answers.
The model
**Q1.** A-. Kestrel's FC LTIDR was A- from 2024-03-12 to 2025-06-20 (E01, A01).
**Q2.** No. The only downgrade was on 2025-06-20 (A02); the 2026-02-10 action (A03) was an affirmation with the outlook moved to Negative.
**Q3.** No. The 2031 note I02 has been BB+ since 2025-06-20, which is below investment grade.
**Q4.** Positive. Northwind Holdings (E02, merged with E03) has an A rating with POS outlook since 2025-09-15 (A09).
**Q5.** E02, rated A. I03 is guaranteed by E02, and I03 itself is rated A (A11).
**Q6.** Not asked in the JSON. The VD ceiling is BB (from 2025-04-01) and E05's FC rating is BB, while its LC rating is BBB-.
**Q7.** 38 issuers had an LTIDR downgrade (DG) starting in 2026; they are listed in the JSON.
**Q8.** E08, whose RD rating has been in force since 2026-07-08 (A22).
**Q9.** 376 distinct rated entities hold a current FC LTIDR (WD excluded). This count includes the sovereign CV.
**Q10.** Depends. E05 is BB on FC (A14) and BBB- on LC (A13), so only the LC rating is investment grade.
**Q11.** BBB+ (E14, A36).
**Q12.** A- (E14, A34).
**Q13.** Once, on 2024-09-30 (A36). The A- to BBB+ move is the only DG on E14.
**Q14.** BB- (E12, A30).
**Q15.** A- (E10, A26).
**Q16.** No. E14 has been BBB+ throughout, and only the watch and outlook changed (A35, A33).
**Q17.** No. E06 stayed at A- and was only placed on Rating Watch Negative on 2026-09-03 (A17).
**Q18.** 32 issuers are on RWN; they are listed in the JSON.
**Q19.** 48 issuers have a NEG outlook; they are listed in the JSON.
**Q20.** No. E07's rating was withdrawn (WD, A19), which is not a default; the only defaulted entity is E08.
**Q21.** 36 entities had an FC LTIDR before but have none in force now (withdrawn or ended); they are listed in the JSON.
**Q22.** E08 only (RD, A22).
**Q23.** F2 (E01, A04).
**Q24.** Yes. The issuer rating is BBB (A03).
**Q25.** 72 instruments.
**Q26.** A+ (E15, A40).
**Q27.** A- (I06, A42).
**Q28.** BBB+ (CV, A38).
**Q29.** None. VD has no rating records.
**Q30.** 13 entities have an FC rating equal to their ceiling; they are listed in the JSON.
**Q31.** No. None of the current FC ratings exceed their ceiling.
**Q32.** E09. E11's parent is E10, and its ultimate parent is E09.
**Q33.** E10, rated BBB+. I05 is guaranteed by E10, and I05 is rated BBB+ (A29).
**Q34.** No. E12 has no parent, while E10 belongs to the E09 group.
**Q35.** 3 (E09, E10, E11).
**Q36.** 2 (E02, E04).
**Q37.** 497, since the entities table is already deduplicated.
**Q38.** No. E06 and E13 are separate entities.
**Q39.** A (E02, A09).
**Q40.** 79.
**Q41.** None. No entity named Brindle exists in the data.
**Q42.** LU (E10).
**Q43.** 1.
**Q44.** Yes. I07 is denominated in XVD with local_currency = yes.
**Q45.** Yes. I07 is rated BBB- (A45) and the VD ceiling is BB.
**Q46.** No. E11 has no rating records.
**Q47.** None. I08 has no rating records.
**Q48.** 113.
**Q49.** E5001.
**Q50.** 6 levels (ancestors table, E5047 to E5001).
**Q51.** 58.
**Q52.** 19.
**Q53.** No. E5062 is in the Belir group (E5059) and E5086 is a separate top entity.
**Q54.** E5106, E5124 and E5130.
**Q55.** 31.
**Q56.** BB- (E5144).
**Q57.** E5002. It is 2 levels above both E5011 and E5013.
**Q58.** E5145, which guarantees I5007 issued by E5133 in the Vesol group.
**Q59.** 12.
**Q60.** E5145 (Geren Group SA). It is not in the same group as the issuer E5133, which is in the E5132 group.
**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","E1058","E1167","E08","E1112","E1169","E1186","E1053","E1057","E1144","E1159","E1243","E5019","E5113","E1064","E1093","E1080","E5116","E1151","E1294","E1051","E1163","E1213","E1300","E5097","E10","E1160","E5059","E1034","E1228","E1229","E1255","E1263","E1298","E1307","E5033","E5156"]},
"Q8":{"entities":["E08"]},
"Q9":{"count":376},
"Q10":{"investment_grade":"depends"},
"Q11":{"rating":"BBB+"},
"Q12":{"rating":"A-"},
"Q13":{"count":1},
"Q14":{"rating":"BB-"},
"Q15":{"rating":"A-"},
"Q16":{"changed":"no"},
"Q17":{"downgraded":"no"},
"Q18":{"issuers":["E1013","E1061","E1238","E1297","E1109","E1168","E1099","E1132","E1260","E1006","E1019","E1264","E06","E1133","E1088","E1194","E1066","E1146","E1203","E1314","E1323","E1037","E1209","E1242","E1317","E1181","E1098","E1126","E1267","E1039","E1059","E1266"]},
"Q19":{"issuers":["E1005","E1080","E5116","E1105","E1158","E1046","E1055","E1294","E5119","E5141","E1034","E1188","E1248","E5057","E1079","E1056","E1059","E1282","E5013","E5023","E5062","E1300","E5097","E5102","E1072","E1190","E5039","E5156","E01","E1064","E1118","E1261","E09","E1211","E5019","E5113","E5131","E1029","E1160","E5020","E5059","E1271","E1228","E1263","E5033","E5050","E5073","E5099"]},
"Q20":{"in_default":"no"},
"Q21":{"entities":["E1007","E1032","E1057","E1155","E1159","E1253","E1308","E1121","E1205","E1206","E1219","E1320","E1244","E1316","E1062","E1277","E1218","E07","E1021","E1166","E1279","E1001","E1124","E1172","E1048","E1084","E1041","E1063","E1107","E1138","E1140","E1200","E1225","E1233","E1234","E1076"]},
"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":["E05","E15","E1028","E1039","E1101","E1126","E1194","E1236","E5012","E5047","E5091","E5116","E5124"]},
"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":"yes"},
"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}
}
```