D1 sql, run 3: the query session

← back to the run

19 queries2 failed7 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` (540 rows): entity_id, name, lei, country, entity_type, parent_id, source_system
- `instruments` (122 rows): instrument_id, description, issuer_id, guarantor_id, seniority, currency, maturity
- `rating_actions` (914 rows): action_id, date, rated_id, rating_type, ccy_basis, action, rating, outlook, watch, comment

## 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
<invoke name="sql">
</invoke>
```sql
select * from entities order by entity_id limit 600;
```


<invoke name="sql">
</invoke>
```sql
select * from instruments order by instrument_id;
```


<invoke name="sql">
</invoke>
```sql
select rating_type, ccy_basis, action, outlook, watch, count(*) from rating_actions group by all order by all;
```
Query results
Query 1:

| entity_id | name | lei | country | entity_type | parent_id | source_system |
|---|---|---|---|---|---|---|
| CV | Republic of Corvenia |  | CV | SOV |  | RATINGS |
| E01 | Kestrel Energy plc | 7245002OOPBG04092E43 | GB | CORP |  | RATINGS |
| E02 | Northwind Holdings plc | 213800PHEIYNJMHTDV74 | GB | CORP |  | RATINGS |
| E03 | NORTHWIND HLDGS | 213800PHEIYNJMHTDV74 | GB | CORP |  | RESEARCH |
| E04 | Northwind Finance BV | 213800LA5RYJLGXV2T85 | NL | FINSUB | E02 | RATINGS |
| E05 | Valdoria Telecom SA | 391200LESH03LMOY2U61 | VD | CORP |  | RATINGS |
| E06 | Orrin Bank AG | 549300AMVE3VRVG7HK43 | DE | BANK |  | RATINGS |
| E07 | Pellam Retail Ltd | 969500B6IUACELPI2291 | GB | CORP |  | RATINGS |
| E08 | Saxby Shipping SA | 969500KOTZ1JFIZSG796 | GR | CORP |  | RATINGS |
| E09 | Halden Group plc | 815600ASM9EHDG931T89 | GB | CORP |  | RATINGS |
| E10 | Halden Bank AG | 391200QYPVFF2O9K2039 | DE | BANK | E09 | RATINGS |
| E1001 | Tunod Steel SA | 3912003R00FP6CNV6210 | FR | CORP |  | RATINGS |
| E1002 | TUNOD STEEL SA | 3912003R00FP6CNV6210 | FR | CORP |  | RESEARCH |
| E1003 | Rilol Telecom plc | 3912009W4J483WB8PZ97 | GB | BANK |  | RATINGS |
| E1004 | Munem Retail SA | 969500IBYK0X2ZT52780 | ES | CORP |  | RATINGS |
| E1005 | Setan Airlines Inc | 815600JRN7AOE36KFR35 | US | CORP |  | RATINGS |
| E1006 | Soson Airlines Inc | 213800WSVEOAQ5HD4C43 | US | CORP | E1005 | RATINGS |
| E1007 | Golod Property plc | 815600N2UAHQREHHWF76 | GB | BANK |  | RATINGS |
| E1008 | Sotil Retail plc | 213800RPNJ2OSQ387M40 | GB | CORP |  | RATINGS |
| E1009 | Malam Chemicals Inc | 3912006EIY6TU9NVSC86 | US | CORP |  | RATINGS |
| E1010 | Buvir Industries Inc | 3912004R2GZJL49URX69 | US | CORP |  | RATINGS |
| E1011 | Falom Media Inc | 549300XX6U9N4Y7KPH74 | US | BANK |  | RATINGS |
| E1012 | Posad Industries SA | 9695002JIQI5QYDN0G98 | FR | CORP |  | RATINGS |
| E1013 | Pisol Pharma BV | 969500U072SAPPW32N81 | NL | BANK | E1004 | RATINGS |
| E1014 | Toral Utilities BV | 391200J700D8T2H18W16 | NL | CORP |  | RATINGS |
| E1015 | Civen Steel Inc | 815600JSNIJ4UFCBF662 | US | CORP |  | RATINGS |
| E1016 | Ponar Telecom SA | 5493008DQ96XI37KZG24 | ES | BANK |  | RATINGS |
| E1017 | Nisid Steel SA | 391200K600X7LWZTTM85 | FR | BANK |  | RATINGS |
| E1018 | Tosem Mining Inc | 549300SEMGL6OXLWHQ59 | US | CORP |  | RATINGS |
| E1019 | Losol Mining SA | 391200GSFO0F68KKUC67 | CV | CORP |  | RATINGS |
| E1020 | Finel Media AG | 549300FCSHHELSCZX562 | DE | CORP |  | RATINGS |
| E1021 | Niner Pharma plc | 391200KLG6G4KVIMIU52 | GB | CORP |  | RATINGS |
| E1022 | NINER PHARMA | 391200KLG6G4KVIMIU52 | GB | CORP |  | RESEARCH |
| E1023 | Heled Water plc | 3912006FHXTH5V6WNK07 | GB | CORP |  | RATINGS |
| E1024 | Susin Shipping BV | 3912005J04HB7X0GTN24 | NL | CORP |  | RATINGS |
| E1025 | Tulol Shipping SA | 2138007MIV2OS05PET94 | ES | BANK |  | RATINGS |
| E1026 | Vunam Water BV | 969500C8XYHXZBFMUO41 | NL | CORP |  | RATINGS |
| E1027 | Tesad Media Inc | 969500T86HNH5S920X18 | US | CORP |  | RATINGS |
| E1028 | Mutir Retail SA | 213800TJ32NARU0BI982 | VD | CORP |  | RATINGS |
| E1029 | Leson Telecom Inc | 8156008DPX4I9DNKWN26 | US | BANK |  | RATINGS |
| E1030 | LESON TELECOM INC | 8156008DPX4I9DNKWN26 | US | BANK |  | RESEARCH |
| E1031 | Kuvir Logistics SA | 969500GRHP48SQNEWH44 | ES | CORP |  | RATINGS |
| E1032 | Helom Chemicals BV | 2138006H9XCYN2P1K228 | NL | BANK |  | RATINGS |
| E1033 | Kunid Pharma SA | 213800Q84PS4FTJJB947 | ES | CORP | E1004 | RATINGS |
| E1034 | Tanad Capital SpA | 815600KLV84WAQGPSX27 | IT | CORP |  | RATINGS |
| E1035 | Kavod Utilities AG | 724500YHN51API4SE179 | DE | CORP |  | RATINGS |
| E1036 | Lilor Retail AG | 9695000N72OQ0Q07IW61 | DE | CORP |  | RATINGS |
| E1037 | Natil Retail SA | 391200OBAXI8590VQN12 | FR | CORP |  | RATINGS |
| E1038 | Lanon Telecom BV | 549300EZ4HXP0L5RAZ01 | NL | CORP |  | RATINGS |
| E1039 | Pulor Airlines SA | 969500HA9D5I7F73PW83 | CV | BANK |  | RATINGS |
| E1040 | Dorid Mining AG | 549300SPMD9MEMFWMR12 | DE | CORP |  | RATINGS |
| E1041 | Hiral Steel SA | 549300JU1O5MP1HSKQ01 | ES | CORP |  | RATINGS |
| E1042 | Rerod Steel BV | 391200LC6V921W096L49 | NL | CORP |  | RATINGS |
| E1043 | Vitom Property plc | 5493007IVTPIWJZLFF29 | GB | CORP |  | RATINGS |
| E1044 | Hesid Telecom Inc | 3912003Y7VZHUGN50755 | US | BANK |  | RATINGS |
| E1045 | Nesid Logistics Inc | 96950029VB162U3K1976 | US | BANK |  | RATINGS |
| E1046 | Ditin Shipping Inc | 549300ZM08IADSAK3L87 | US | BANK | E1026 | RATINGS |
| E1047 | Vaved Pharma plc | 391200WGA8OE30KZUD08 | GB | CORP | E1020 | RATINGS |
| E1048 | Lised Pharma AG | 9695000T21G05UQMGF10 | DE | CORP |  | RATINGS |
| E1049 | Paser Utilities plc | 391200R2EH7FELZFOV27 | GB | CORP |  | RATINGS |
(480 more rows not shown)

Query 2:

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

Query 3:

| rating_type | ccy_basis | action | outlook | watch | count_star() |
|---|---|---|---|---|---|
| CC |  | AS |  |  | 2 |
| CO |  | AS |  |  | 7 |
| INST |  | AF |  |  | 1 |
| INST |  | AS |  |  | 113 |
| INST |  | DG |  |  | 3 |
| INST |  | EX |  |  | 9 |
| LTIDR | FC | AF | NEG |  | 22 |
| LTIDR | FC | AF | POS |  | 15 |
| LTIDR | FC | AF | STA |  | 44 |
| LTIDR | FC | AS | NEG |  | 1 |
| LTIDR | FC | AS | STA |  | 425 |
| LTIDR | FC | DG | NEG |  | 47 |
| LTIDR | FC | DG | POS |  | 24 |
| LTIDR | FC | DG | STA |  | 35 |
| LTIDR | FC | DG |  |  | 2 |
| LTIDR | FC | RW |  | RWN | 45 |
| LTIDR | FC | UG | NEG |  | 8 |
| LTIDR | FC | UG | POS |  | 10 |
| LTIDR | FC | UG | STA |  | 27 |
| LTIDR | FC | WD |  |  | 39 |
| LTIDR | LC | AF | POS |  | 1 |
| LTIDR | LC | AF | STA |  | 3 |
| LTIDR | LC | AS | STA |  | 19 |
| LTIDR | LC | DG | NEG |  | 1 |
| LTIDR | LC | DG | POS |  | 1 |
| LTIDR | LC | DG | STA |  | 2 |
| LTIDR | LC | RW |  | RWN | 3 |
| LTIDR | LC | UG | POS |  | 1 |
| LTIDR | LC | UG | STA |  | 2 |
| LTIDR | LC | WD |  |  | 1 |
| STIDR | FC | AF |  |  | 1 |

Run more queries, or give the final answers.
The model
```sql
select * from rating_actions where rated_id in ('E01','E02','E03','E04','E05','E06','E07','E08','E09','E10','E11','E15','CV','I01','I02','I03','I04','I05','I06','I07','I08') order by rated_id, date;
```

```sql
select * from entities where entity_id not like 'E1%' or entity_id in ('E11','E15') order by entity_id;
```

```sql
select distinct comment from rating_actions where comment is not null and comment<>'' limit 80;
```
Query results
Query 1:

| action_id | date | rated_id | rating_type | ccy_basis | action | rating | outlook | watch | comment |
|---|---|---|---|---|---|---|---|---|---|
| A39 | 2024-01-01 | CV | LTIDR | LC | AS | A- | STA |  |  |
| A38 | 2024-01-01 | CV | LTIDR | FC | AS | BBB+ | STA |  |  |
| A37 | 2024-01-01 | CV | CC |  | AS | A |  |  |  |
| A01 | 2024-03-12 | E01 | LTIDR | FC | AS | A- | STA |  |  |
| A02 | 2025-06-20 | E01 | LTIDR | FC | DG | BBB | STA |  | weaker cash flow after asset sale |
| A03 | 2026-02-10 | E01 | LTIDR | FC | AF | BBB | NEG |  |  |
| A04 | 2026-02-10 | E01 | STIDR | FC | AF | F2 |  |  |  |
| A08 | 2023-11-01 | E02 | LTIDR | FC | AS | A | STA |  |  |
| A09 | 2025-09-15 | E03 | LTIDR | FC | AF | A | POS |  |  |
| A13 | 2025-04-01 | E05 | LTIDR | LC | AS | BBB- | STA |  |  |
| A14 | 2025-04-01 | E05 | LTIDR | FC | AS | BB | STA |  |  |
| A16 | 2024-05-01 | E06 | LTIDR | FC | AS | A- | STA |  |  |
| A17 | 2026-09-03 | E06 | LTIDR | FC | RW | A- |  | RWN |  |
| A18 | 2024-01-10 | E07 | LTIDR | FC | AS | BB | STA |  |  |
| A19 | 2026-05-12 | E07 | LTIDR | FC | WD | WD |  |  | commercial reasons |
| A20 | 2024-06-01 | E08 | LTIDR | FC | AS | B | STA |  |  |
| A21 | 2026-01-20 | E08 | LTIDR | FC | DG | CCC |  |  |  |
| A22 | 2026-07-08 | E08 | LTIDR | FC | DG | RD |  |  | distressed debt exchange completed |
| A24 | 2023-05-01 | E09 | LTIDR | FC | AS | A | STA |  |  |
| A25 | 2026-03-01 | E09 | LTIDR | FC | AF | A | NEG |  |  |
| A26 | 2023-05-01 | E10 | LTIDR | FC | AS | A- | STA |  | support from parent |
| A27 | 2026-04-15 | E10 | LTIDR | FC | DG | BBB+ | STA |  |  |
| A46 | 2025-02-01 | E11 | CO |  | AS | BBB |  |  |  |
| A40 | 2024-03-01 | E15 | LTIDR | LC | AS | A+ | STA |  |  |
| A41 | 2024-03-01 | E15 | LTIDR | FC | AS | A | STA |  |  |
| A05 | 2024-03-12 | I01 | INST |  | AS | A- |  |  |  |
| A06 | 2025-06-20 | I01 | INST |  | DG | BBB |  |  |  |
| A23 | 2024-03-12 | I02 | INST |  | AS | BBB |  |  |  |
| A07 | 2025-06-20 | I02 | INST |  | DG | BB+ |  |  |  |
| A10 | 2023-11-01 | I03 | INST |  | AS | A |  |  |  |
| A11 | 2025-09-15 | I03 | INST |  | AF | A |  |  |  |
| A15 | 2025-04-01 | I04 | INST |  | AS | BB |  |  |  |
| A28 | 2023-06-01 | I05 | INST |  | AS | A- |  |  |  |
| A29 | 2026-04-15 | I05 | INST |  | DG | BBB+ |  |  |  |
| A42 | 2024-03-01 | I06 | INST |  | AS | A- |  |  |  |
| A45 | 2025-04-01 | I07 | INST |  | AS | BBB- |  |  |  |
| A47 | 2026-09-01 | I08 | INST |  | EX | A |  |  |  |

Query 2:

| entity_id | name | lei | country | entity_type | parent_id | source_system |
|---|---|---|---|---|---|---|
| CV | Republic of Corvenia |  | CV | SOV |  | RATINGS |
| E01 | Kestrel Energy plc | 7245002OOPBG04092E43 | GB | CORP |  | RATINGS |
| E02 | Northwind Holdings plc | 213800PHEIYNJMHTDV74 | GB | CORP |  | RATINGS |
| E03 | NORTHWIND HLDGS | 213800PHEIYNJMHTDV74 | GB | CORP |  | RESEARCH |
| E04 | Northwind Finance BV | 213800LA5RYJLGXV2T85 | NL | FINSUB | E02 | RATINGS |
| E05 | Valdoria Telecom SA | 391200LESH03LMOY2U61 | VD | CORP |  | RATINGS |
| E06 | Orrin Bank AG | 549300AMVE3VRVG7HK43 | DE | BANK |  | RATINGS |
| E07 | Pellam Retail Ltd | 969500B6IUACELPI2291 | GB | CORP |  | RATINGS |
| E08 | Saxby Shipping SA | 969500KOTZ1JFIZSG796 | GR | CORP |  | RATINGS |
| E09 | Halden Group plc | 815600ASM9EHDG931T89 | GB | CORP |  | RATINGS |
| E11 | Halden Leasing SA | 549300XBZH4ULO9MQV55 | FR | FINSUB | E10 | RATINGS |
| E15 | Corvenia Power SA | 213800PBQVHVBBH6GV02 | CV | CORP |  | RATINGS |
| E5001 | Cerid Group plc | 815600F48PANJQE75352 | GB | CORP |  | RATINGS |
| E5002 | Cerid Energy plc | 3912006ACANJUP8PLJ39 | GB | CORP | E5001 | RATINGS |
| E5003 | Cerid Media BV | 724500EXQA91TPK6WL60 | NL | CORP | E5001 | RATINGS |
| E5004 | Cerid Utilities plc | 969500SFWGRHVUTANY40 | GB | CORP | E5001 | RATINGS |
| E5005 | Cerid Chemicals SA | 391200B1GR4AGTV5WY99 | VD | CORP | E5002 | RATINGS |
| E5006 | Cerid Foods plc | 969500HZQBDFIIHLYK06 | GB | BANK | E5002 | RATINGS |
| E5007 | Cerid Holdings BV | 391200Q98UGZZQTV1C88 | NL | CORP | E5003 | RATINGS |
| E5008 | Cerid Airlines BV | 815600M8RE9386DDQB31 | NL | CORP | E5003 | RATINGS |
| E5009 | Cerid Leror Logistics plc | 96950033222B9BRCGP58 | GB | CORP | E5004 | RATINGS |
| E5010 | Cerid Gator Steel Inc | 724500E2OQMMMZVTBS53 | US | CORP | E5004 | RATINGS |
| E5011 | Cerid Guven Energy SA | 391200IX7WB68Q29NJ46 | VD | CORP | E5167 | RATINGS |
| E5012 | Cerid Gevin Pharma SA | 549300TPHB19IJU6VV67 | VD | CORP | E5005 | RATINGS |
| E5013 | Cerid Telecom SA | 724500EU84AMOZS7U244 | ES | BANK | E5006 | RATINGS |
| E5014 | Cerid Gusom Pharma SpA | 724500YWGS7BR1AKHD13 | IT | CORP | E5006 | RATINGS |
| E5015 | Cerid Logistics BV | 969500C1TQV008QIYL28 | NL | CORP | E5007 | RATINGS |
| E5016 | Cerid Rovem Industries BV | 549300WMHA09HQ7NGF72 | NL | CORP | E5007 | RATINGS |
| E5017 | Cerid Steel BV | 213800BAYNUVR2EE0Y41 | NL | CORP | E5008 | RATINGS |
| E5018 | Cerid Mining BV | 815600DDEIUOIMDS3N14 | NL | CORP | E5008 | RATINGS |
| E5019 | Cerid Buvom Mining plc | 2138002W9KTVILKQ8Q89 | GB | CORP | E5009 | RATINGS |
| E5020 | Cerid Tivim Retail SA | 9695003VHLA8O9WU7N54 | FR | BANK | E5009 | RATINGS |
| E5021 | Cerid Retail Inc | 724500S8Q4HUNT229Y84 | US | CORP | E5010 | RATINGS |
| E5022 | Cerid Industries Inc | 213800S7QJ9EVK96PK05 | US | CORP | E5010 | RATINGS |
| E5023 | Cerid Dilal Utilities SA | 549300MXQ7UU7852PG70 | VD | CORP | E5011 | RATINGS |
| E5024 | Cerid Fatal Shipping SA | 39120041ZCI02VDN2I18 | VD | CORP | E5012 | RATINGS |
| E5025 | Cerid Fater Media SA | 213800AXPZD5MSP2GW32 | ES | CORP | E5013 | RATINGS |
| E5026 | Cerid Hosad Retail Inc | 724500GF9ADSAA20FI77 | US | CORP | E5014 | RATINGS |
| E5027 | Cerid Hutem Water plc | 391200TO1KK187R1JQ78 | GB | CORP | E5015 | RATINGS |
| E5028 | Cerid Galon Chemicals BV | 724500EVQNRETR9CVD02 | NL | BANK | E5016 | RATINGS |
| E5029 | Cerid Walol Water BV | 21380057HMIY2LIM5A29 | NL | BANK | E5017 | RATINGS |
| E5030 | Cerid Tivor Holdings BV | 549300M13MMEINCT8W03 | NL | CORP | E5018 | RATINGS |
| E5031 | Cerid Velin Water plc | 815600Q07VLOKJE53L06 | GB | CORP | E5019 | RATINGS |
| E5032 | Cerid Meron Media SA | 213800CIZLWWL071KP85 | FR | CORP | E5020 | RATINGS |
| E5033 | Cerid Pitam Energy Inc | 969500799KP9QCVM7739 | US | CORP | E5021 | RATINGS |
| E5034 | Cerid Shipping BV | 7245008XDA202762F829 | NL | CORP | E5022 | RATINGS |
| E5035 | Cerid Water SA | 724500637K0GA6PFC081 | VD | BANK | E5023 | RATINGS |
| E5036 | Cerid Calin Energy SpA | 549300RJ7KMPDJVQY167 | IT | CORP | E5024 | RATINGS |
| E5037 | Cerid Holom Water SA | 2138003NRPV4IDSP9314 | ES | CORP | E5025 | RATINGS |
| E5038 | Cerid Holen Chemicals BV | 969500HETRKT6OQMNS48 | NL | CORP | E5026 | RATINGS |
| E5039 | Cerid Property SA | 549300DBENKHP53C1C31 | ES | CORP | E5027 | RATINGS |
| E5040 | Cerid Lovan Energy BV | 9695007VBLZNWG66LZ43 | NL | CORP | E5028 | RATINGS |
| E5041 | Cerid Dolem Mining AG | 391200FXD4CH3FVZ4165 | DE | BANK | E5029 | RATINGS |
| E5042 | Cerid Feral Property BV | 724500N6QZUJJJ1BJI79 | NL | BANK | E5030 | RATINGS |
| E5043 | Cerid Retil Chemicals plc | 724500TQEHDQ1U12GG60 | GB | CORP | E5031 | RATINGS |
| E5044 | Cerid Masim Retail plc | 969500Q2MORWVR40BH37 | GB | CORP | E5032 | RATINGS |
| E5045 | Cerid Curel Water SA | 7245006QVOPQQK3JUP45 | CV | CORP | E5033 | RATINGS |
| E5046 | Cerid Gevom Media BV | 5493004EWDCN8OTFZZ22 | NL | CORP | E5034 | RATINGS |
| E5047 | Cerid Rosor Holdings SA | 8156004CDHFBVRR3LT54 | VD | BANK | E5035 | RATINGS |
| E5048 | Cerid Pharma plc | 969500Z6AXSJ33YYZX35 | GB | CORP | E5036 | RATINGS |
(123 more rows not shown)

Query 3:

| comment |
|---|
| commercial reasons |
| distressed debt exchange completed |
| weaker cash flow after asset sale |
| support from parent |

Run more queries, or give the final answers.
The model
```sql
select * from entities where name ilike any ('%Marlow%','%Halden%','%Brindle%','%Orrin%','%Belir%','%Rotam%','%Wonod%','%Vesol%','%Valdoria%','%Corvenia%','%Cerid Rosor%','%Cerid Guven%','%Cerid Telecom%') order by entity_id;
```

```sql
select * from rating_actions where rating_type in ('CC','CO') or rated_id in (select entity_id from entities where name ilike any ('%Marlow%','%Halden%','%Brindle%','%Orrin%')) order by rated_id,date;
```

```sql
select * from instruments where instrument_id not like 'I10%' and instrument_id not like 'I11%' or guarantor_id is not null or description ilike '%cross%' order by instrument_id;
```

```sql
select country, count(distinct entity_id) from entities where country in ('LU') group by all;
select count(*), count(distinct lei), count(distinct case when source_system='RATINGS' then entity_id end) from entities;
```
Query results
Query 1 failed: Parser Error: syntax error at or near ","

Query 2 failed: Parser Error: syntax error at or near ","

Query 3:

| instrument_id | description | issuer_id | guarantor_id | seniority | currency | maturity |
|---|---|---|---|---|---|---|
| I01 | Kestrel Energy 4.50% notes due 2030 | E01 |  | SU | GBP | 2030-03-15 |
| I02 | Kestrel Energy 6.25% notes due 2031 | E01 |  | SUB | GBP | 2031-09-30 |
| I03 | Northwind Finance 3.75% notes due 2030 | E04 | E02 | SU | EUR | 2030-05-01 |
| I04 | Valdoria Telecom 5.00% notes due 2029 | E05 |  | SU | USD | 2029-11-20 |
| I05 | Halden Leasing 2.90% notes due 2028 | E11 | E10 | SU | EUR | 2028-06-30 |
| I06 | Corvenia Power 7.10% notes due 2032 | E15 |  | SUB | USD | 2032-02-15 |
| I07 | Valdoria Telecom 4.25% notes due 2027 | E05 |  | SU | XVD | 2027-08-31 |
| I08 | Corvenia Power 6.00% notes due 2034 | E15 |  | SU | USD | 2034-09-01 |
| I1093 | Poval Chemicals Finance 2.50% notes due 2034 | E1325 | E1084 | SU | EUR | 2027-03-31 |
| I1094 | Witad Steel Finance 6.50% notes due 2027 | E1326 | E1052 | SU | EUR | 2033-03-31 |
| I1095 | Nuner Holdings Finance 4.50% notes due 2032 | E1327 | E1119 | SU | EUR | 2030-03-31 |
| I1096 | Palad Mining Finance 6.50% notes due 2030 | E1328 | E1244 | SU | EUR | 2028-03-31 |
| I1097 | Ganen Shipping Finance 5.50% notes due 2030 | E1329 | E1069 | SU | EUR | 2029-03-31 |
| I1098 | Niner Pharma Finance 3.50% notes due 2030 | E1330 | E1021 | SU | EUR | 2032-03-31 |
| I1099 | Tulol Shipping Finance 3.50% notes due 2034 | E1331 | E1025 | SU | EUR | 2032-03-31 |
| I1100 | Sanin Mining Finance 2.50% notes due 2032 | E1332 | E1068 | SU | EUR | 2028-03-31 |
| I1101 | Gilen Capital Finance 3.50% notes due 2031 | E1333 | E1082 | SU | EUR | 2034-03-31 |
| I1102 | Votim Industries Finance 3.50% notes due 2027 | E1334 | E1260 | SU | EUR | 2031-03-31 |
| I1103 | Belor Telecom Finance 2.50% notes due 2027 | E1335 | E1234 | SU | EUR | 2030-03-31 |
| I1104 | Navor Holdings Finance 2.50% notes due 2029 | E1336 | E1176 | SU | EUR | 2033-03-31 |
| I1105 | Lanon Telecom Finance 5.50% notes due 2028 | E1337 | E1038 | SU | EUR | 2034-03-31 |
| I1106 | Hivor Industries Finance 6.50% notes due 2027 | E1338 | E1073 | SU | EUR | 2033-03-31 |
| I1107 | Wivin Airlines Finance 2.50% notes due 2031 | E1339 | E1241 | SU | EUR | 2030-03-31 |
| I5001 | Cerid Funding 4.25% notes due 2033 | E5005 | E5001 | SU | EUR | 2030-12-31 |
| I5002 | Belir Funding 5.25% notes due 2035 | E5062 | E5059 | SU | EUR | 2029-12-31 |
| I5003 | Rotam Funding 3.25% notes due 2032 | E5090 | E5086 | SU | EUR | 2033-12-31 |
| I5004 | Wonod Funding 4.25% notes due 2032 | E5108 | E5105 | SU | EUR | 2032-12-31 |
| I5005 | Vesol Funding 7.25% notes due 2033 | E5135 | E5132 | SU | EUR | 2030-12-31 |
| I5006 | Geren Funding 7.25% notes due 2030 | E5149 | E5145 | SU | EUR | 2032-12-31 |
| I5007 | Cross-group 4.75% notes due 2031 | E5133 | E5145 | SU | USD | 2031-06-30 |

Query 4:

| count_star() | count(DISTINCT lei) | count(DISTINCT CASE  WHEN ((source_system = 'RATINGS')) THEN (entity_id) ELSE NULL END) |
|---|---|---|
| 540 | 509 | 497 |

Run more queries, or give the final answers.
The model
```sql
select * from entities where regexp_matches(name,'Marlow|Halden|Brindle|Orrin|Belir|Rotam|Wonod|Vesol|Valdoria|Corvenia|Cerid Rosor|Cerid Guven|Cerid Telecom') or country in ('LU') order by entity_id;
```

```sql
select * from rating_actions where rating_type in ('CC','CO') or rated_id in (select entity_id from entities where regexp_matches(name,'Marlow|Halden|Brindle|Orrin')) order by rated_id,date;
```

```sql
select * from entities where entity_id in ('E5001','E5059','E5086','E5105','E5132','E5145','E5133','E5167') or parent_id in ('E5167');
```
Query results
Query 1:

| entity_id | name | lei | country | entity_type | parent_id | source_system |
|---|---|---|---|---|---|---|
| CV | Republic of Corvenia |  | CV | SOV |  | RATINGS |
| E05 | Valdoria Telecom SA | 391200LESH03LMOY2U61 | VD | CORP |  | RATINGS |
| E06 | Orrin Bank AG | 549300AMVE3VRVG7HK43 | DE | BANK |  | RATINGS |
| E09 | Halden Group plc | 815600ASM9EHDG931T89 | GB | CORP |  | RATINGS |
| E10 | Halden Bank AG | 391200QYPVFF2O9K2039 | DE | BANK | E09 | RATINGS |
| E11 | Halden Leasing SA | 549300XBZH4ULO9MQV55 | FR | FINSUB | E10 | RATINGS |
| E12 | Halden Foods Ltd | 213800IJDL4OJ4DG5T19 | GB | CORP |  | RATINGS |
| E13 | Orrin Bancorp Inc | 815600O8X8K2F154N214 | US | BANK |  | RATINGS |
| E14 | Marlow Utilities plc | 3912005AH2C1I9YF8106 | GB | CORP |  | RATINGS |
| E15 | Corvenia Power SA | 213800PBQVHVBBH6GV02 | CV | CORP |  | RATINGS |
| E16 | Brindle Capital Ltd | 5493003Z3PXXR7KNFM81 | GB | CORP |  | QA |
| E17 | HALDEN BANK | 391200QYPVFF2O9K2039 | LU | BANK |  | RESEARCH |
| E5011 | Cerid Guven Energy SA | 391200IX7WB68Q29NJ46 | VD | CORP | E5167 | RATINGS |
| E5013 | Cerid Telecom SA | 724500EU84AMOZS7U244 | ES | BANK | E5006 | RATINGS |
| E5047 | Cerid Rosor Holdings SA | 8156004CDHFBVRR3LT54 | VD | BANK | E5035 | RATINGS |
| E5059 | Belir Group AG | 969500YPO4CFVEL1XX12 | DE | CORP |  | RATINGS |
| E5060 | Belir Retail AG | 549300PQXT9OXKZVXP03 | DE | CORP | E5059 | RATINGS |
| E5061 | Belir Steel Inc | 5493004QWM1AN9Q59M90 | US | BANK | E5059 | RATINGS |
| E5062 | Belir Mining SA | 54930011OTFCAUKB0A28 | FR | CORP | E5060 | RATINGS |
| E5063 | Belir Harem Property AG | 391200DIHCC3BA4VZZ12 | DE | CORP | E5060 | RATINGS |
| E5064 | Belir Holdings plc | 724500Q0JKSMWBXVBU93 | GB | CORP | E5061 | RATINGS |
| E5065 | Belir Nelad Property AG | 549300L03V06VLA93J12 | DE | CORP | E5061 | RATINGS |
| E5066 | Belir Shipping SA | 2138006F3FLNO4C1FU85 | FR | CORP | E5062 | RATINGS |
| E5067 | Belir Capital AG | 724500PEM92TFIBH3E89 | DE | CORP | E5063 | RATINGS |
| E5068 | Belir Kator Energy plc | 969500LH6R0LMYUZA394 | GB | CORP | E5064 | RATINGS |
| E5069 | Belir Water SA | 391200PZ4I0VQJK2W457 | FR | CORP | E5065 | RATINGS |
| E5070 | Belir Rusin Media SA | 8156004IQIH39FK9VH78 | FR | CORP | E5066 | RATINGS |
| E5071 | Belir Chemicals SA | 724500EPR0DH4ZXK1N07 | FR | CORP | E5066 | RATINGS |
| E5072 | Belir Katin Telecom AG | 815600R2EBVJ16RD3A20 | DE | CORP | E5067 | RATINGS |
| E5073 | Belir Puvir Mining plc | 549300Z4E2ZBV3ZWA751 | GB | CORP | E5067 | RATINGS |
| E5074 | Belir Industries plc | 549300KXQ2S560AVV453 | GB | CORP | E5068 | RATINGS |
| E5075 | Belir Gitid Industries plc | 815600DW5IX6LC8W8V29 | GB | CORP | E5068 | RATINGS |
| E5076 | Belir Property SA | 96950092K7EM4MPGLP04 | FR | CORP | E5069 | RATINGS |
| E5077 | Belir Media SA | 213800PX54IYKA21SV31 | FR | CORP | E5069 | RATINGS |
| E5078 | Belir Vasin Water plc | 969500OGDTR8B14SH139 | GB | BANK | E5070 | RATINGS |
| E5079 | Belir Sitom Logistics SA | 213800N76YAEEVTGC136 | FR | CORP | E5071 | RATINGS |
| E5080 | Belir Foods AG | 815600W19TGJNKXFFO22 | DE | CORP | E5072 | RATINGS |
| E5081 | Belir Vusad Telecom SA | 549300C58DC34KK7FK00 | VD | CORP | E5073 | RATINGS |
| E5082 | Belir Bovid Telecom plc | 815600N0YPG44MRFH213 | GB | BANK | E5074 | RATINGS |
| E5083 | Belir Airlines plc | 815600VWRV7PTZ2G2598 | GB | CORP | E5075 | RATINGS |
| E5084 | Belir Luton Media SA | 815600NALYO1JPB0Y303 | FR | BANK | E5076 | RATINGS |
| E5085 | Belir Rutel Water SA | 213800K6R3NB1ZT7Y709 | CV | CORP | E5077 | RATINGS |
| E5086 | Rotam Group Inc | 213800PJV1XFQEKJ1L86 | US | CORP |  | RATINGS |
| E5087 | Rotam Mining Inc | 724500OT1LFBVAVBRI55 | US | CORP | E5086 | RATINGS |
| E5088 | Rotam Industries Inc | 72450088A4BIGJ0A1N08 | US | CORP | E5086 | RATINGS |
| E5089 | Rotam Airlines Inc | 7245008N6U91AB1U1398 | US | CORP | E5086 | RATINGS |
| E5090 | Rotam Logistics Inc | 724500J7FCE6HMEBB653 | US | CORP | E5087 | RATINGS |
| E5091 | Rotam Water SA | 7245007V26QZ8EY8MZ45 | VD | CORP | E5088 | RATINGS |
| E5092 | Rotam Hison Holdings Inc | 391200GBH7B6XVDLYP36 | US | CORP | E5089 | RATINGS |
| E5093 | Rotam Telecom Inc | 391200SIBITK6V9AYU16 | US | CORP | E5090 | RATINGS |
| E5094 | Rotam Holdings Inc | 72450096SJSRDS8ZI255 | US | CORP | E5090 | RATINGS |
| E5095 | Rotam Energy BV | 815600HA1HK1TIMKR785 | NL | BANK | E5091 | RATINGS |
| E5096 | Rotam Lulel Mining SA | 549300CUU7XMKSLTTB66 | ES | BANK | E5091 | RATINGS |
| E5097 | Rotam Chemicals Inc | 3912008BZ54JQ8UNFG51 | US | BANK | E5092 | RATINGS |
| E5098 | Rotam Pharma SA | 815600LW5B06S1CQW672 | CV | CORP | E5092 | RATINGS |
| E5099 | Rotam Fived Water Inc | 815600UU6JEHIIMLC927 | US | CORP | E5093 | RATINGS |
| E5100 | Rotam Property Inc | 724500GA08KIJSPLUI93 | US | BANK | E5094 | RATINGS |
| E5101 | Rotam Foods BV | 724500VSL9A06KR45I76 | NL | CORP | E5095 | RATINGS |
| E5102 | Rotam Utilities SA | 96950092DKV427KADB93 | ES | CORP | E5096 | RATINGS |
| E5103 | Rotam Goson Energy Inc | 724500LIPSS64F2BVY06 | US | CORP | E5097 | RATINGS |
(42 more rows not shown)

Query 2:

| action_id | date | rated_id | rating_type | ccy_basis | action | rating | outlook | watch | comment |
|---|---|---|---|---|---|---|---|---|---|
| A37 | 2024-01-01 | CV | CC |  | AS | A |  |  |  |
| A16 | 2024-05-01 | E06 | LTIDR | FC | AS | A- | STA |  |  |
| A17 | 2026-09-03 | E06 | LTIDR | FC | RW | A- |  | RWN |  |
| A24 | 2023-05-01 | E09 | LTIDR | FC | AS | A | STA |  |  |
| A25 | 2026-03-01 | E09 | LTIDR | FC | AF | A | NEG |  |  |
| A26 | 2023-05-01 | E10 | LTIDR | FC | AS | A- | STA |  | support from parent |
| A27 | 2026-04-15 | E10 | LTIDR | FC | DG | BBB+ | STA |  |  |
| A46 | 2025-02-01 | E11 | CO |  | AS | BBB |  |  |  |
| A30 | 2024-02-01 | E12 | LTIDR | FC | AS | BB- | STA |  |  |
| A31 | 2025-08-01 | E12 | LTIDR | FC | UG | BB | STA |  |  |
| A32 | 2024-07-01 | E13 | LTIDR | FC | AS | BBB | STA |  |  |
| A1698 | 2026-09-02 | E1326 | CO |  | AS | BB |  |  |  |
| A1700 | 2025-06-13 | E1327 | CO |  | AS | BBB- |  |  |  |
| A1704 | 2025-06-27 | E1330 | CO |  | AS | BB+ |  |  |  |
| A1708 | 2024-08-17 | E1333 | CO |  | AS | BBB+ |  |  |  |
| A1713 | 2026-11-16 | E1337 | CO |  | AS | BBB+ |  |  |  |
| A1715 | 2026-07-04 | E1338 | CO |  | AS | BBB+ |  |  |  |
| A34 | 2023-01-15 | E14 | LTIDR | FC | AS | A- | STA |  |  |
| A36 | 2024-09-30 | E14 | LTIDR | FC | DG | BBB+ | STA |  |  |
| A35 | 2025-11-20 | E14 | LTIDR | FC | RW | BBB+ |  | RWN |  |
| A33 | 2026-05-01 | E14 | LTIDR | FC | AF | BBB+ | STA |  |  |
| A43 | 2024-04-01 | E16 | LTIDR | FC | AS | BBB- | STA |  |  |
| A44 | 2026-06-01 | E16 | LTIDR | FC | DG | BB+ | STA |  |  |
| A12 | 2025-04-01 | VD | CC |  | AS | BB |  |  |  |

Query 3:

| entity_id | name | lei | country | entity_type | parent_id | source_system |
|---|---|---|---|---|---|---|
| E5001 | Cerid Group plc | 815600F48PANJQE75352 | GB | CORP |  | RATINGS |
| E5011 | Cerid Guven Energy SA | 391200IX7WB68Q29NJ46 | VD | CORP | E5167 | RATINGS |
| E5059 | Belir Group AG | 969500YPO4CFVEL1XX12 | DE | CORP |  | RATINGS |
| E5086 | Rotam Group Inc | 213800PJV1XFQEKJ1L86 | US | CORP |  | RATINGS |
| E5105 | Wonod Group SA | 7245003GC3MAPLM74H56 | FR | CORP |  | RATINGS |
| E5132 | Vesol Group BV | 724500QJUUI5LKTI3C20 | NL | CORP |  | RATINGS |
| E5133 | Vesol Foods plc | 969500J32JMVAGT5XX78 | GB | BANK | E5132 | RATINGS |
| E5145 | Geren Group SA | 8156002XDJU2OFI9JC47 | VD | CORP |  | RATINGS |
| E5167 | CERID CHEMICALS SA | 391200B1GR4AGTV5WY99 | VD | CORP |  | RESEARCH |

Run more queries, or give the final answers.
The model
<invoke name="sql">
</invoke>
```sql
with c as (select entity_id, country, arg_min(entity_id, case when source_system='RATINGS' then 0 else 1 end) over (partition by coalesce(lei,entity_id)) cid from entities),
ra as (select r.*, coalesce(c.cid, r.rated_id) cid from rating_actions r left join c on c.entity_id=r.rated_id),
st as (select * from ra where date<='2026-10-01' qualify row_number() over (partition by cid, rating_type, coalesce(ccy_basis,'') order by date desc, action_id desc)=1)
select cid, ccy_basis, action, rating, outlook, watch, date from st where rating_type='LTIDR' and ccy_basis='FC' and (rating in ('RD','D','C') or action='WD' or watch='RWN' or outlook='NEG') order by action, cid;
```
```sql
with c as (select entity_id, country, arg_min(entity_id, case when source_system='RATINGS' then 0 else 1 end) over (partition by coalesce(lei,entity_id)) cid from entities),
ra as (select r.*, coalesce(c.cid, r.rated_id) cid from rating_actions r left join c on c.entity_id=r.rated_id)
select 'dg2026' k, cid, rating_type, ccy_basis, action, rating, date from ra where action='DG' and date>='2026-01-01'
union all select 'default', cid, rating_type, ccy_basis, action, rating, date from ra where rating in ('RD','D','C')
union all select 'EX/AF-inst', cid, rating_type, ccy_basis, action, rating, date from ra where rating_type='INST' and action in ('EX','AF')
order by 1,2;
```
```sql
with c as (select entity_id, country, arg_min(entity_id, case when source_system='RATINGS' then 0 else 1 end) over (partition by coalesce(lei,entity_id)) cid from entities),
ra as (select r.*, coalesce(c.cid, r.rated_id) cid from rating_actions r left join c on c.entity_id=r.rated_id),
st as (select * from ra where date<='2026-10-01' qualify row_number() over (partition by cid, rating_type, coalesce(ccy_basis,'') order by date desc, action_id desc)=1),
ent as (select * from entities where entity_id in (select cid from c))
select 'issuers_with_rating' k, count(distinct st.cid) n, count(distinct case when e.country='GB' then st.cid end) gb from st join ent e on e.entity_id=st.cid where rating_type='LTIDR' and action<>'WD'
union all select 'ever_issuer_not_now', count(distinct cid), 0 from ra where rating_type='LTIDR' and cid not in (select cid from st where rating_type='LTIDR' and action<>'WD')
union all select 'inst_rated_nonEX', count(*), count(*) filter (where rating in ('AAA','AA+','AA','AA-','A+','A','A-','BBB+','BBB','BBB-')) from st where rating_type='INST' and action<>'EX'
union all select 'distinct_entities', count(*), count(*) filter (where country='LU') from ent
union all select 'research_dupes', count(*), 0 from entities where source_system<>'RATINGS';
```
```sql
with c as (select entity_id, country, arg_min(entity_id, case when source_system='RATINGS' then 0 else 1 end) over (partition by coalesce(lei,entity_id)) cid from entities),
ra as (select r.*, coalesce(c.cid, r.rated_id) cid from rating_actions r left join c on c.entity_id=r.rated_id),
st as (select * from ra where date<='2026-10-01' qualify row_number() over (partition by cid, rating_type, coalesce(ccy_basis,'') order by date desc, action_id desc)=1)
select e.entity_id, e.country, st.rating, st.action, st.date from st join entities e on e.entity_id=st.cid where st.rating_type='LTIDR' and st.ccy_basis='FC' and e.country in ('CV','VD') and st.action<>'WD'
union all select entity_id, country, 'ENTITY', source_system, null from entities where name ilike '%Republic%' or entity_id in ('VD','E17') or country='LU';
```
Query results
Query 1:

| cid | ccy_basis | action | rating | outlook | watch | date |
|---|---|---|---|---|---|---|
| E01 | FC | AF | BBB | NEG |  | 2026-02-10 |
| E09 | FC | AF | A | NEG |  | 2026-03-01 |
| E1059 | FC | AF | BB- | NEG |  | 2025-02-16 |
| E1072 | FC | AF | BB- | NEG |  | 2026-02-07 |
| E1079 | FC | AF | BB+ | NEG |  | 2024-01-26 |
| E1158 | FC | AF | BBB | NEG |  | 2026-08-14 |
| E1211 | FC | AF | BBB- | NEG |  | 2024-09-26 |
| E1248 | FC | AF | A- | NEG |  | 2026-05-02 |
| E1261 | FC | AF | B+ | NEG |  | 2024-10-13 |
| E1271 | FC | AF | A- | NEG |  | 2025-10-15 |
| E1282 | FC | AF | BB+ | NEG |  | 2024-03-20 |
| E5170 | FC | AS | B- | NEG |  | 2026-03-01 |
| E08 | FC | DG | RD |  |  | 2026-07-08 |
| E1005 | FC | DG | BB | NEG |  | 2025-08-02 |
| E1034 | FC | DG | BBB+ | NEG |  | 2026-05-02 |
| E1056 | FC | DG | A+ | NEG |  | 2023-01-01 |
| E1080 | FC | DG | A- | NEG |  | 2026-02-14 |
| E1118 | FC | DG | BB+ | NEG |  | 2025-07-14 |
| E1160 | FC | DG | B | NEG |  | 2026-07-28 |
| E1228 | FC | DG | BB+ | NEG |  | 2026-06-28 |
| E1263 | FC | DG | BBB- | NEG |  | 2026-06-16 |
| E1294 | FC | DG | A+ | NEG |  | 2026-07-11 |
| E1300 | FC | DG | BBB | NEG |  | 2026-05-06 |
| E1340 | FC | DG | BBB+ | NEG |  | 2026-06-26 |
| E1342 | FC | DG | BBB+ | NEG |  | 2026-07-17 |
| E1343 | FC | DG | BBB+ | NEG |  | 2026-08-08 |
| E1344 | FC | DG | A- | NEG |  | 2026-03-18 |
| E1345 | FC | DG | BB- | NEG |  | 2026-09-22 |
| E1347 | FC | DG | BBB- | NEG |  | 2026-03-10 |
| E1348 | FC | DG | BBB- | NEG |  | 2026-03-18 |
| E1350 | FC | DG | BB | NEG |  | 2026-09-03 |
| E1351 | FC | DG | A- | NEG |  | 2026-09-27 |
| E5013 | FC | DG | B- | NEG |  | 2024-06-01 |
| E5019 | FC | DG | BBB+ | NEG |  | 2026-03-19 |
| E5020 | FC | DG | BBB+ | NEG |  | 2024-07-26 |
| E5023 | FC | DG | B- | NEG |  | 2025-06-20 |
| E5039 | FC | DG | BB- | NEG |  | 2025-04-08 |
| E5050 | FC | DG | BBB+ | NEG |  | 2025-03-25 |
| E5057 | FC | DG | A | NEG |  | 2025-10-04 |
| E5059 | FC | DG | BB+ | NEG |  | 2026-05-25 |
| E5062 | FC | DG | B- | NEG |  | 2025-02-08 |
| E5073 | FC | DG | BBB- | NEG |  | 2024-02-01 |
| E5097 | FC | DG | B- | NEG |  | 2026-08-16 |
| E5099 | FC | DG | BB- | NEG |  | 2025-04-23 |
| E5102 | FC | DG | BBB- | NEG |  | 2024-01-14 |
| E5113 | FC | DG | BB- | NEG |  | 2026-06-21 |
| E5116 | FC | DG | A | NEG |  | 2026-05-16 |
| E5119 | FC | DG | A | NEG |  | 2025-05-20 |
| E5131 | FC | DG | B | NEG |  | 2025-11-22 |
| E5141 | FC | DG | BB | NEG |  | 2024-08-13 |
| E5156 | FC | DG | B- | NEG |  | 2026-02-16 |
| E06 | FC | RW | A- |  | RWN | 2026-09-03 |
| E1006 | FC | RW | AA |  | RWN | 2026-06-17 |
| E1013 | FC | RW | BB- |  | RWN | 2025-07-09 |
| E1037 | FC | RW | A |  | RWN | 2022-05-07 |
| E1039 | FC | RW | A |  | RWN | 2025-12-09 |
| E1061 | FC | RW | A |  | RWN | 2025-06-06 |
| E1066 | FC | RW | A- |  | RWN | 2026-05-03 |
| E1088 | FC | RW | B+ |  | RWN | 2024-01-16 |
| E1098 | FC | RW | BBB- |  | RWN | 2026-04-28 |
(64 more rows not shown)

Query 2:

| k | cid | rating_type | ccy_basis | action | rating | date |
|---|---|---|---|---|---|---|
| EX/AF-inst | I03 | INST |  | AF | A | 2025-09-15 |
| EX/AF-inst | I08 | INST |  | EX | A | 2026-09-01 |
| EX/AF-inst | I1001 | INST |  | EX | A+ | 2026-11-17 |
| EX/AF-inst | I1007 | INST |  | EX | AA- | 2026-11-11 |
| EX/AF-inst | I1008 | INST |  | EX | B+ | 2026-05-23 |
| EX/AF-inst | I1012 | INST |  | EX | A- | 2026-07-22 |
| EX/AF-inst | I1015 | INST |  | EX | B+ | 2026-12-17 |
| EX/AF-inst | I1021 | INST |  | EX | AA- | 2026-09-18 |
| EX/AF-inst | I1046 | INST |  | EX | B+ | 2026-05-18 |
| EX/AF-inst | I1049 | INST |  | EX | BB- | 2026-03-17 |
| default | E08 | LTIDR | FC | DG | RD | 2026-07-08 |
| dg2026 | E08 | LTIDR | FC | DG | RD | 2026-07-08 |
| dg2026 | E08 | LTIDR | FC | DG | CCC | 2026-01-20 |
| dg2026 | E10 | LTIDR | FC | DG | BBB+ | 2026-04-15 |
| dg2026 | E1034 | LTIDR | FC | DG | BBB+ | 2026-05-02 |
| dg2026 | E1051 | LTIDR | FC | DG | A+ | 2026-04-05 |
| dg2026 | E1051 | LTIDR | FC | DG | A+ | 2026-06-01 |
| dg2026 | E1053 | LTIDR | FC | DG | BB | 2026-03-20 |
| dg2026 | E1057 | LTIDR | FC | DG | BB | 2026-06-25 |
| dg2026 | E1058 | LTIDR | FC | DG | BBB- | 2026-07-14 |
| dg2026 | E1064 | LTIDR | FC | DG | BBB+ | 2026-03-04 |
| dg2026 | E1080 | LTIDR | FC | DG | A- | 2026-02-14 |
| dg2026 | E1093 | LTIDR | FC | DG | B | 2026-07-25 |
| dg2026 | E1112 | LTIDR | FC | DG | BBB | 2026-02-20 |
| dg2026 | E1144 | LTIDR | FC | DG | B+ | 2026-06-06 |
| dg2026 | E1151 | LTIDR | FC | DG | BBB | 2026-01-26 |
| dg2026 | E1159 | LTIDR | FC | DG | BBB+ | 2026-06-16 |
| dg2026 | E1160 | LTIDR | FC | DG | B | 2026-07-28 |
| dg2026 | E1163 | LTIDR | FC | DG | BB+ | 2026-03-19 |
| dg2026 | E1167 | LTIDR | FC | DG | BB | 2026-09-07 |
| dg2026 | E1169 | LTIDR | FC | DG | BB- | 2026-08-16 |
| dg2026 | E1186 | LTIDR | FC | DG | BBB+ | 2026-01-04 |
| dg2026 | E1213 | LTIDR | FC | DG | BBB+ | 2026-06-16 |
| dg2026 | E1213 | LTIDR | FC | DG | A- | 2026-02-13 |
| dg2026 | E1228 | LTIDR | FC | DG | BB+ | 2026-06-28 |
| dg2026 | E1229 | LTIDR | FC | DG | BB | 2026-05-06 |
| dg2026 | E1229 | LTIDR | FC | DG | BB+ | 2026-06-02 |
| dg2026 | E1243 | LTIDR | FC | DG | BB | 2026-01-13 |
| dg2026 | E1255 | LTIDR | FC | DG | BBB+ | 2026-01-19 |
| dg2026 | E1263 | LTIDR | FC | DG | BBB | 2026-03-03 |
| dg2026 | E1263 | LTIDR | FC | DG | BBB- | 2026-06-16 |
| dg2026 | E1285 | LTIDR | FC | DG | A | 2026-02-17 |
| dg2026 | E1290 | LTIDR | FC | DG | B | 2026-08-16 |
| dg2026 | E1294 | LTIDR | FC | DG | A+ | 2026-07-11 |
| dg2026 | E1298 | LTIDR | FC | DG | BBB | 2026-02-06 |
| dg2026 | E1300 | LTIDR | FC | DG | BBB+ | 2026-04-09 |
| dg2026 | E1300 | LTIDR | FC | DG | BBB | 2026-05-06 |
| dg2026 | E1307 | LTIDR | FC | DG | BB- | 2026-02-08 |
| dg2026 | E1340 | LTIDR | FC | DG | BBB+ | 2026-06-26 |
| dg2026 | E1341 | LTIDR | FC | DG | BBB+ | 2026-11-09 |
| dg2026 | E1342 | LTIDR | FC | DG | BBB+ | 2026-07-17 |
| dg2026 | E1343 | LTIDR | FC | DG | BBB+ | 2026-08-08 |
| dg2026 | E1344 | LTIDR | FC | DG | A- | 2026-03-18 |
| dg2026 | E1345 | LTIDR | FC | DG | BB- | 2026-09-22 |
| dg2026 | E1346 | LTIDR | FC | DG | BBB+ | 2026-10-15 |
| dg2026 | E1347 | LTIDR | FC | DG | BBB- | 2026-03-10 |
| dg2026 | E1348 | LTIDR | FC | DG | BBB- | 2026-03-18 |
| dg2026 | E1349 | LTIDR | FC | DG | A- | 2026-10-14 |
| dg2026 | E1350 | LTIDR | FC | DG | BB | 2026-09-03 |
| dg2026 | E1351 | LTIDR | FC | DG | A- | 2026-09-27 |
(9 more rows not shown)

Query 3:

| k | n | gb |
|---|---|---|
| issuers_with_rating | 391 | 87 |
| ever_issuer_not_now | 35 | 0 |
| inst_rated_nonEX | 113 | 72 |
| distinct_entities | 511 | 0 |
| research_dupes | 43 | 0 |

Query 4:

| entity_id | country | rating | action | date |
|---|---|---|---|---|
| E05 | VD | BB | AS | 2025-04-01 |
| CV | CV | BBB+ | AS | 2024-01-01 |
| E15 | CV | A | AS | 2024-03-01 |
| E1019 | CV | BB+ | AS | 2022-12-11 |
| E1028 | VD | BB | UG | 2025-12-25 |
| E1039 | CV | A | RW | 2025-12-09 |
| E1059 | CV | BB- | AF | 2025-02-16 |
| E1071 | CV | B+ | AS | 2023-01-11 |
| E1096 | CV | BBB | AS | 2024-04-04 |
| E1101 | VD | BB | AS | 2022-10-26 |
| E1106 | VD | B+ | AS | 2024-10-26 |
| E1126 | VD | BB | RW | 2025-07-10 |
| E1136 | CV | A- | AS | 2023-07-04 |
| E1144 | CV | B+ | DG | 2026-06-06 |
| E1185 | CV | BB+ | AS | 2025-02-28 |
| E1194 | CV | A | RW | 2025-01-20 |
| E1217 | CV | BB- | AS | 2025-09-07 |
| E1223 | CV | BB+ | AS | 2023-08-20 |
| E1229 | CV | BB+ | DG | 2026-06-02 |
| E1236 | VD | BB | AS | 2023-09-17 |
| E1243 | CV | BB | AF | 2026-08-19 |
| E1245 | CV | B+ | UG | 2025-09-11 |
| E1283 | CV | BB | UG | 2024-11-03 |
| E1304 | CV | BB | UG | 2026-07-25 |
| E1307 | VD | BB- | AF | 2026-09-25 |
| E1313 | VD | BB- | DG | 2025-09-02 |
| E5012 | VD | BB | AS | 2022-03-08 |
| E5023 | VD | B- | DG | 2025-06-20 |
| E5024 | VD | B- | AS | 2024-05-10 |
| E5047 | VD | BB | AS | 2022-07-23 |
| E5091 | VD | BB | AS | 2024-04-08 |
| E5098 | CV | B- | AS | 2023-04-09 |
| E5104 | CV | BB | AS | 2022-01-15 |
| E5116 | CV | A | DG | 2026-05-16 |
| E5117 | CV | BB | AS | 2023-10-15 |
| E5124 | VD | BB | AS | 2024-11-20 |
| E5127 | CV | B | AS | 2025-09-20 |
| E5130 | VD | B- | AS | 2025-10-01 |
| E5170 | VD | B- | AS | 2026-03-01 |
| VD | VD | ENTITY | RATINGS |  |
| CV | CV | ENTITY | RATINGS |  |
| E17 | LU | ENTITY | RESEARCH |  |

Run more queries, or give the final answers.
The model
<invoke name="sql">
</invoke>
```sql
create or replace temp table c as select entity_id, arg_min(entity_id, case when source_system='RATINGS' then 0 else 1 end) over (partition by coalesce(lei,entity_id)) cid from entities;
create or replace temp table ent as select e.*, (select cid from c where c.entity_id=e.parent_id) pcid from entities e where entity_id in (select cid from c);
create or replace temp table anc as with recursive r(eid, anc, lvl) as (select entity_id, pcid, 1 from ent where pcid is not null union all select r.eid, e.pcid, lvl+1 from r join ent e on e.entity_id=r.anc where e.pcid is not null) select * from r;
create or replace temp table root as select e.entity_id eid, coalesce((select anc from anc a where a.eid=e.entity_id order by lvl desc limit 1), e.entity_id) root, coalesce((select max(lvl) from anc a where a.eid=e.entity_id),0) depth from ent e;
create or replace temp table ra as select r.*, coalesce(c.cid, r.rated_id) cid from rating_actions r left join c on c.entity_id=r.rated_id;
create or replace temp table st as select * from ra where date<='2026-10-01' qualify row_number() over (partition by cid, rating_type, coalesce(ccy_basis,'') order by date desc, action_id desc)=1;
select 'Q7', string_agg(distinct cid, ',') from ra where rating_type='LTIDR' and action='DG' and date between '2026-01-01' and '2026-12-31'
union all select 'Q18', string_agg(cid, ',') from st where rating_type='LTIDR' and watch='RWN'
union all select 'Q19', string_agg(cid, ',') from st where rating_type='LTIDR' and outlook='NEG' and action<>'WD'
union all select 'Q8', string_agg(cid, ',') from st where rating_type='LTIDR' and rating in ('RD','D')
union all select 'Q21', string_agg(distinct cid, ',') from ra where rating_type='LTIDR' and date<='2026-10-01' and cid not in (select cid from st where rating_type='LTIDR' and action<>'WD')
union all select 'grp '||root, count(*)||' | '||string_agg(eid,',') filter (where root in ('E09','E02') or eid='E5047') from root where root in ('E09','E02','E5001','E5086','E5105','E5132') group by root
union all select 'Q50', eid||' root '||root||' depth '||depth from root where eid in ('E5047','E5062','E5011','E5013','E5133','E5145')
union all select 'Q54', string_agg(r.eid,',') from root r join ent e on e.entity_id=r.eid where root='E5105' and country='VD'
union all select 'Q57', string_agg(a.anc||':'||a.lvl||'/'||b.lvl,',') from anc a join anc b on a.anc=b.anc and a.eid='E5011' and b.eid='E5013'
union all select 'Q59', count(*)::varchar from root where root='E5001' and depth=3
union all select 'Q61', count(*)::varchar from root r join st on st.cid=r.eid and st.rating_type='LTIDR' and st.ccy_basis='FC' and st.action<>'WD' where r.root='E5001' and st.rating not in ('AAA','AA+','AA','AA-','A+','A','A-','BBB+','BBB','BBB-')
union all select 'Q56', string_agg(r.eid||'='||st.rating,',') from root r join st on st.cid=r.eid and st.rating_type='LTIDR' and st.ccy_basis='FC' and st.action<>'WD' where r.root='E5132'
union all select 'Q55', count(distinct st.cid)::varchar from st where rating_type='LTIDR' and action<>'WD' and cid in (select a.eid from anc a join ent e on e.entity_id=a.anc where e.country='VD')
union all select 'Q58', string_agg(i.instrument_id||':'||i.guarantor_id||'>'||i.issuer_id,',') from instruments i join root a on a.eid=i.issuer_id join root b on b.eid=i.guarantor_id where a.root<>b.root;
```
Query results
Query 1:

| 'Q7' | string_agg(DISTINCT cid, ',') |
|---|---|
| Q7 | E1034,E1080,E5116,E1064,E1343,E1093,E1167,E1058,E1341,E1344,E10,E5059,E1160,E1351,E1342,E1053,E1144,E5019,E1159,E1057,E1243,E5113,E1051,E1347,E5097,E1163,E1213,E1300,E1290,E1285,E1307,E1345,E1229,E1298,E1263,E1255,E5033,E1228,E1349,E1350,E1294,E1151,E16,E1340,E1346,E08,E1169,E1348,E1186,E1112,E5156 |
| Q18 | E1099,E1260,E1006,E1297,E1132,E1181,E1323,E1266,E1019,E1037,E1203,E1267,E06,E1039,E1088,E1098,E1146,E1066,E1314,E1061,E1126,E1133,E1059,E1109,E1168,E1194,E1209,E1242,E1264,E1238,E1317,E1013 |
| Q19 | E1034,E1118,E1190,E1343,E5039,E5113,E5119,E1105,E1160,E5116,E1228,E1282,E1300,E1345,E1350,E5099,E01,E1055,E1079,E1158,E1261,E1340,E1342,E5013,E5156,E1059,E5019,E5059,E5141,E1056,E1072,E1080,E1347,E1005,E1271,E5097,E5170,E1064,E5057,E5073,E1248,E09,E1046,E1263,E1344,E1348,E1351,E5020,E5050,E5131,E1211,E5023,E5102,E1029,E1188,E1294,E5062 |
| Q8 | E08 |
| Q21 | E1062,E1225,E1200,E1234,E1233,E1253,E1155,E1032,E1007,E1308,E1057,E1159,E1121,E1205,E1316,E1244,E1048,E1084,E1277,E1219,E1206,E1320,E1076,E07,E1021,E1166,E1172,E1124,E1001,E1218,E1140,E1041,E1107,E1063,E1138 |
| grp E09 | 3 | E10,E11,E09 |
| grp E02 | 2 | E04,E02 |
| grp E5105 |  |
| grp E5086 |  |
| grp E5132 |  |
| grp E5001 | 59 | E5047 |
| Q50 | E5011 root E5001 depth 3 |
| Q50 | E5013 root E5001 depth 3 |
| Q50 | E5047 root E5001 depth 6 |
| Q50 | E5062 root E5059 depth 2 |
| Q50 | E5133 root E5132 depth 1 |
| Q50 | E5145 root E5145 depth 0 |
| Q54 | E5124,E5130 |
| Q57 | E5002:2/2,E5001:3/3 |
| Q59 | 12 |
| Q61 | 20 |
| Q56 | E5140=A+,E5133=BBB-,E5141=BB,E5132=BB+,E5136=BBB-,E5144=BB-,E5143=A |
| Q55 | 23 |
| Q58 | I5007:E5145>E5133 |

Run more queries, or give the final answers.
The model
<invoke name="sql">
</invoke>
```sql
with recursive r(eid, root) as (select entity_id, entity_id from entities where entity_id in ('E5086') union all select e.entity_id, r.root from entities e join r on e.parent_id=r.eid) select root, count(*), count(distinct (select lei from entities x where x.entity_id=r.eid)) from r group by root;
```
Query results
Query 1:

| root | count_star() | count(DISTINCT (SELECT lei FROM entities AS x WHERE (x.entity_id = r.eid))) |
|---|---|---|
| E5086 | 20 | 20 |

Run more queries, or give the final answers.
The model
**Q1.** A-. Kestrel's rating was A- from A01 (2024-03-12). The downgrade to BBB came later, in A02 (2025-06-20).

**Q2.** No. A03 (2026-02-10) only affirmed BBB and changed the outlook to Negative.

**Q3.** No. Instrument I02 (the 2031 note) is rated BB+ since A07, below investment grade.

**Q4.** Positive. E02 and E03 share an LEI, so I treated them as one entity. The latest action, A09 (2025-09-15), is Positive.

**Q5.** The risk is Northwind Holdings (E02), rated A. Instrument I03 is issued by E04 and guaranteed by E02, and A09/A11 affirm A.

**Q6.** The data doesn't state a reason. E05's foreign-currency rating is BB (A14) and its local-currency rating is BBB- (A13). The country ceiling for VD is BB (A12), which is consistent with the gap, but no record says it is the cause.

**Q7.** The list is in the JSON; it counts issuers with a 2026 downgrade (DG) action dated on or before today (2026-11-05). I excluded E1341, whose downgrade is dated 2026-11-09. Inclusion of any other future-dated downgrades hasn't been checked.

**Q8.** E08 (Saxby Shipping). It was downgraded to RD on 2026-07-08 (A22) after a distressed debt exchange.

**Q9.** 391. This counts distinct de-duplicated entities (same LEI) whose latest long-term issuer rating on 1 Oct 2026 was not a withdrawal.

**Q10.** Depends. Valdoria Telecom (E05) is BB in foreign currency (A14, sub-investment grade) and BBB- in local currency (A13, investment grade).

**Q11.** BBB+. E14 was downgraded in A36 (2024-09-30), and the Rating Watch Negative in A35 only came on 2025-11-20.

**Q12.** A-. This is from A34 (2023-01-15).

**Q13.** 1. The only downgrade of E14 is A36.

**Q14.** None. E12's first rating is A30, dated 2024-02-01.

**Q15.** A-. A27 (downgrade to BBB+) came only on 2026-04-15.

**Q16.** No. The rating stayed BBB+ (A36 through A33). A35 was a watch and A33 an affirmation.

**Q17.** No. A17 (2026-09-03) only placed E06 on Rating Watch Negative at A-.

**Q18.** The list is in the JSON (32 issuers whose latest issuer rating was a Rating Watch Negative action).

**Q19.** The list is in the JSON; it includes E01 and E09.

**Q20.** No. E07's rating was withdrawn for commercial reasons (A19), and it was never rated in default.

**Q21.** The list is in the JSON (35 entities, including E07). Each had an issuer rating that was later withdrawn.

**Q22.** E08 only. It is the only entity with an RD, D or C rating (A22).

**Q23.** F2, from A04.

**Q24.** Yes. The BBB issuer rating (A03) is investment grade.

**Q25.** 72. This is the number of instruments whose latest rating on 1 Oct 2026 was investment grade and not an expiry (EX).

**Q26.** A+, from A40.

**Q27.** A-, from A42 for I06.

**Q28.** BBB+, from A38.

**Q29.** None. The entity VD has only a Country Ceiling (BB, A12) and no issuer rating.

**Q30.** The list is in the JSON. The ceilings are CV = A (A37) and VD = BB (A12); the list is entities in each country whose foreign-currency rating equals it.

**Q31.** No. No CV entity is above A and no VD entity is above BB.

**Q32.** E09. E11 has parent E10, and E10 has parent E09.

**Q33.** The risk is Halden Bank (E10), rated BBB+. I05 is guaranteed by E10, and A27 downgraded E10 to BBB+.

**Q34.** No. E12 (Halden Foods) has no parent, while E10 sits under E09.

**Q35.** 3: E09, E10 and E11.

**Q36.** 2: E02 and E04.

**Q37.** 511. This is 540 rows with duplicates of the same LEI merged.

**Q38.** No. They have different LEIs and are separate entities, E06 and E13.

**Q39.** A. A09 affirmed A on 2025-09-15, after A08 assigned A.

**Q40.** 87. This counts distinct GB-domiciled de-duplicated issuers with an issuer rating on 1 Oct 2026.

**Q41.** BB+. A44 (2026-06-01) downgraded E16 from BBB-. Note E16's source system is QA.

**Q42.** DE (E10). E17 is a duplicate record with the same LEI that shows LU.

**Q43.** 0. The only LU record, E17, is a duplicate of E10, which is DE.

**Q44.** Yes. I07 is denominated in XVD, the Valdoria currency.

**Q45.** No. The BB ceiling (A12) applies to foreign currency, and I07 is a local-currency obligation rated BBB- (A45).

**Q46.** No. E11 has only a credit opinion (CO, A46) and no long-term issuer rating.

**Q47.** None. I08's latest action, A47 (2026-09-01), is an expiry, so it has no current rating.

**Q48.** 113. This is the number of instruments with a live rating on 1 Oct 2026.

**Q49.** E5001. The chain is E5047 to E5035, E5023, E5011, E5005, E5002, then E5001.

**Q50.** 6. E5047 sits at depth 6 below E5001.

**Q51.** 59, counting E5001 and de-duplicating E5167 (the same LEI as E5005).

**Q52.** 20, counting Rotam Group Inc (E5086) and every descendant.

**Q53.** No. E5062 sits under E5059 (Belir Group AG), and E5086 is a separate root.

**Q54.** E5124 and E5130.

**Q55.** 23.

**Q56.** BB-. This is E5144; the other members hold higher ratings (E5133 BBB-, E5141 BB, E5132 BB+).

**Q57.** E5002. It is the nearest common ancestor, two levels above both E5011 and E5013.

**Q58.** E5145. It guarantees I5007, issued by E5133 in the Vesol group.

**Q59.** 12.

**Q60.** The risk is Geren Group SA (E5145). It is not in the same group as the issuer E5133, which is in Vesol.

**Q61.** 20.

```json
{"Q1":{"rating":"A-"},"Q2":{"downgraded":"no"},"Q3":{"investment_grade":"no","rating":"BB+"},"Q4":{"outlook":"Positive"},"Q5":{"risk_of":"E02","rating":"A"},"Q7":{"issuers":["E1034","E1080","E5116","E1064","E1343","E1093","E1167","E1058","E1344","E10","E5059","E1160","E1351","E1342","E1053","E1144","E5019","E1159","E1057","E1243","E5113","E1051","E1347","E5097","E1163","E1213","E1300","E1290","E1285","E1307","E1345","E1229","E1298","E1263","E1255","E5033","E1228","E1349","E1350","E1294","E1151","E16","E1340","E1346","E08","E1169","E1348","E1186","E1112","E5156"]},"Q8":{"entities":["E08"]},"Q9":{"count":391},"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":["E1099","E1260","E1006","E1297","E1132","E1181","E1323","E1266","E1019","E1037","E1203","E1267","E06","E1039","E1088","E1098","E1146","E1066","E1314","E1061","E1126","E1133","E1059","E1109","E1168","E1194","E1209","E1242","E1264","E1238","E1317","E1013"]},"Q19":{"issuers":["E1034","E1118","E1190","E1343","E5039","E5113","E5119","E1105","E1160","E5116","E1228","E1282","E1300","E1345","E1350","E5099","E01","E1055","E1079","E1158","E1261","E1340","E1342","E5013","E5156","E1059","E5019","E5059","E5141","E1056","E1072","E1080","E1347","E1005","E1271","E5097","E5170","E1064","E5057","E5073","E1248","E09","E1046","E1263","E1344","E1348","E1351","E5020","E5050","E5131","E1211","E5023","E5102","E1029","E1188","E1294","E5062"]},"Q20":{"in_default":"no"},"Q21":{"entities":["E1062","E1225","E1200","E1234","E1233","E1253","E1155","E1032","E1007","E1308","E1057","E1159","E1121","E1205","E1316","E1244","E1048","E1084","E1277","E1219","E1206","E1320","E1076","E07","E1021","E1166","E1172","E1124","E1001","E1218","E1140","E1041","E1107","E1063","E1138"]},"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":["E15","E1039","E1194","E5116","E05","E1028","E1101","E1126","E1236","E5012","E5047","E5091","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":511},"Q38":{"same":"no"},"Q39":{"rating":"A"},"Q40":{"count":87},"Q41":{"rating":"BB+"},"Q42":{"country":"DE"},"Q43":{"count":0},"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":59},"Q52":{"count":20},"Q53":{"same_group":"no"},"Q54":{"entities":["E5124","E5130"]},"Q55":{"count":23},"Q56":{"rating":"BB-"},"Q57":{"entity":"E5002"},"Q58":{"entities":["E5145"]},"Q59":{"count":12},"Q60":{"risk_of":"E5145","same_group":"no"},"Q61":{"count":20}}
```