D2 sql+markdown, run 3: the query session
18 queries3 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` (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
### ontology.md (the vocabulary the data uses)
# Credit ratings: a teaching ontology
Entities, instruments, rating actions and the codes the data uses, each with a definition that states what it means and how to read it. Invented for an experiment; not a model of any real rating agency.
## Classes
### Entity
A legal entity: a company, bank, finance subsidiary or sovereign. An entity is identified by its LEI (LEI), not by its name or record ID. The data holds records from more than one source system (source system), so the same entity can appear as several records with different IDs and differently spelled names: two records with the same LEI are the same entity, and every fact recorded against either record is a fact about that one entity.
### Instrument
A debt instrument, such as a bond or note, issued by an entity (issuer). An instrument's rating is not the issuer's rating: it can sit above or below it depending on seniority (seniority) and on any guarantee (guarantor).
### Rating action
Something a rating agency did to a rating on a date (date): assigned, affirmed, upgraded, downgraded, placed on Watch or withdrawn it. Each action applies to one rated thing (rated thing), one rating type (rating type) and, for issuer ratings, one currency basis (currency basis). A rating holds from its action date until the next action on the same thing, type and basis: so the rating on a date D is the one set by the latest action on or before D, and the current rating is the latest action overall. rating always holds the rating as it stands after the action, including when it did not change.
## Properties
### name (CSV column `name`)
The name as the source system spells it. Names are not identifiers: the same entity can be spelled differently in different systems.
### LEI (CSV column `lei`)
Legal Entity Identifier: the identifier that says which legal entity a record describes. Same LEI, same entity. Sovereigns have none.
### country (CSV column `country`)
ISO-style code of the country where the entity is domiciled. Where an entity's records disagree, see source system for which holds. It decides which Country Ceiling, if any, applies to the entity's foreign-currency ratings. VD is the Republic of Valdoria and CV the Republic of Corvenia (both invented).
### entity type (CSV column `entity_type`)
What kind of entity it is: a concept of the scheme Entity types.
### parent (CSV column `parent_id`)
The entity that owns and controls this one. A parent link names a record, but points at the entity that record describes, so the chain continues from any of that entity's records. Following parents up to an entity with no parent gives the ultimate parent; a group is an ultimate parent and every entity whose chain of parents ends at it.
### source system (CSV column `source_system`)
The internal system the record comes from (RATINGS, RESEARCH, QA). Each system keeps its own records of the same entities; see Entity. Where records of the same entity disagree, which one holds depends on the field. RATINGS is the system of record for names and parent links. Domicile is the exception: the RESEARCH team checks each entity's registered office against its filings, so where records disagree on country, the RESEARCH record holds. QA records are test data, created to check the systems: they describe no real entity, so a QA record, and every action recorded against it, must be ignored.
### description (CSV column `description`)
The instrument's name: issuer, coupon and maturity year.
### issuer (CSV column `issuer_id`)
The entity that issued the instrument and owes the payments. Not necessarily the entity whose credit risk the investor takes: see guarantor.
### guarantor (CSV column `guarantor_id`)
An entity that guarantees the instrument's payments if the issuer does not pay. A guaranteed instrument carries the guarantor's credit risk, so it is rated in line with the guarantor's issuer rating, not the issuer's.
### seniority (CSV column `seniority`)
Where the instrument ranks in repayment if the issuer fails: a concept of the scheme Seniorities.
### currency (CSV column `currency`)
The currency the instrument pays in, as an ISO 4217 code, or one of two local codes: XVD, the Valdorian dollar, the domestic currency of VD; and CVK, the Corvenian krone, the domestic currency of CV. Debt in a currency other than the domestic one of the issuer's country is exposed to that country's transfer and convertibility risk: see Country Ceiling (CC). Debt in the domestic currency is local-currency debt and is not capped by the ceiling.
### maturity (CSV column `maturity`)
The date the instrument is due to be repaid.
### date (CSV column `date`)
The date the action took effect.
### rated thing (CSV column `rated_id`)
What the action is about: an entity (for issuer ratings and Country Ceilings) or an instrument (for instrument ratings).
### rating type (CSV column `rating_type`)
Which kind of rating the action concerns: a concept of the scheme Rating types. Different types are different ratings and are never compared or combined with each other.
### currency basis (CSV column `ccy_basis`)
For issuer ratings, whether the rating covers foreign-currency (FC) or local-currency (LC) obligations: a concept of the scheme Currency bases. An entity can have both, with different values.
### action (CSV column `action`)
What was done: a concept of the scheme Action types. Only upgrades and downgrades change a rating.
### rating (CSV column `rating`)
The rating after the action, on the scale of its rating type. Long-term scale, strongest to weakest: AAA, AA+, AA, AA-, A+, A, A-, BBB+, BBB, BBB-, BB+, BB, BB-, B+, B, B-, CCC, CC, C, RD, D. Investment grade means BBB- or higher; BB+ and below is speculative grade (high yield). RD (restricted default) means the issuer has defaulted on some material obligations, for instance by completing a distressed debt exchange, without being wound up: RD is a default. D means a general default. Short-term scale, strongest to weakest: F1+, F1, F2, F3, B, C, RD, D. WD means the rating was withdrawn (see Withdrawn (WD)): it is not a point on either scale.
### outlook (CSV column `outlook`)
The likely direction of a long-term rating over the next one to two years: a concept of the scheme Outlooks. An outlook is not a rating: revising it does not change the rating.
### rating watch (CSV column `watch`)
Set when the rating is on Rating Watch: a concept of the scheme Rating Watches. A Watch is not a rating change.
### comment (CSV column `comment`)
The analyst's note on the action, such as the reason for a withdrawal.
## Codes
The codes as they appear in the data, grouped by list.
### Rating types
- **LTIDR**, Long-term Issuer Default Rating: The issuer's own creditworthiness: how likely it is to default on its obligations, on the long-term scale. This is what people usually mean by an entity's rating. The foreign-currency (FC) one is the headline rating; there may also be a local-currency (LC) one.
- **STIDR**, Short-term Issuer Default Rating: The issuer's ability to meet obligations falling due within about a year, on the short-term scale (F1+ to D). Not comparable with long-term ratings.
- **INST**, Instrument rating: The rating of one specific instrument. It starts from the issuer's long-term rating and is notched for the instrument's seniority and expected recovery: subordinated debt is usually rated below the issuer, and guaranteed debt is rated on the guarantor. An instrument rating is never the rating of the issuer.
- **CC**, Country Ceiling: Not a rating of anyone. A cap, set for a country, on the foreign-currency ratings of entities domiciled there and of their foreign-currency debt. It reflects transfer and convertibility risk: the risk that the government stops money being converted or sent abroad, so even a sound company could not pay foreign-currency debt. Foreign-currency ratings of entities in the country are generally no higher than the ceiling; local-currency ratings are not capped. A Country Ceiling is not the sovereign's own issuer rating.
- **CO**, Credit opinion: A private, point-in-time view of an entity's credit, given to one client. It is not a published rating and not an issuer rating: never count it as a rating, and never report its value as the entity's rating.
### Currency bases
- **FC**, Foreign currency: Covers obligations in foreign currency, so it is subject to the Country Ceiling.
- **LC**, Local currency: Covers obligations in the currency of the entity's own country; not subject to the Country Ceiling.
### Action types
- **AS**, Assigned: A first rating is given.
- **AF**, Affirmed: The rating is reviewed and kept the same. The outlook may be revised in the same action; that does not make it an upgrade or a downgrade.
- **UG**, Upgraded: The rating is raised.
- **DG**, Downgraded: The rating is lowered. The only action that counts as a downgrade.
- **RW**, Placed on Rating Watch: The rating is flagged as likely to change soon, usually within about six months, in the direction rating watch gives. The rating itself is unchanged: not a downgrade.
- **WD**, Withdrawn: The agency stops maintaining the rating, often for commercial reasons (the issuer no longer pays for it, or the debt is repaid). After a withdrawal the entity has no rating of that type. A withdrawal is not a credit event: it says nothing about default, and is not a downgrade.
- **EX**, Expected rating: A rating signalled before an instrument's final documents are signed. It is not yet a rating: the instrument stays unrated until an Assigned (AS) action confirms it.
### Outlooks
- **STA**, Stable: No direction expected.
- **POS**, Positive: The rating may go up over one to two years.
- **NEG**, Negative: The rating may go down over one to two years. Not a downgrade.
### Rating Watches
- **RWN**, Rating Watch Negative: A downgrade is likely in the near term. Not a downgrade yet.
### Seniorities
- **SU**, Senior unsecured: Ranks with the issuer's ordinary debts; usually rated at the level of the issuer's long-term rating.
- **SUB**, Subordinated: Repaid only after senior debt, so investors recover less in a default; usually rated one or more notches below the issuer's long-term rating.
### Entity types
- **CORP**, Corporate: A non-financial company.
- **BANK**, Bank: A bank.
- **FINSUB**, Finance subsidiary: A subsidiary that exists to raise debt for its parent group. It usually has no issuer rating of its own; its debt is guaranteed by the parent, so investors take the parent's credit risk.
- **SOV**, Sovereign: A national government. A sovereign record can carry a Country Ceiling, issuer ratings, or both: they are different things, and the ceiling is not the sovereign's rating.
## 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 entities.
```sql
SELECT * FROM entities ORDER BY name, entity_id;
```
```sql
SELECT * FROM instruments ORDER BY issuer_id;
```Query results
Query 1:
| entity_id | name | lei | country | entity_type | parent_id | source_system |
|---|---|---|---|---|---|---|
| E5168 | BELIR MINING SA | 54930011OTFCAUKB0A28 | FR | CORP | E5086 | RESEARCH |
| E1057 | Batan Foods plc | 2138009BPHEDKSZHFF68 | GB | BANK | | RATINGS |
| E1278 | Bavil Chemicals plc | 815600LDQIUCNNTOL286 | GB | CORP | | RATINGS |
| E1308 | Bavom Logistics AG | 549300IGMPC8HEIKND87 | DE | CORP | | RATINGS |
| E1292 | Bavon Industries plc | 549300RN36RWXRZPV988 | GB | CORP | E1061 | RATINGS |
| E5083 | Belir Airlines plc | 815600VWRV7PTZ2G2598 | GB | CORP | E5075 | RATINGS |
| E5082 | Belir Bovid Telecom plc | 815600N0YPG44MRFH213 | GB | BANK | E5074 | RATINGS |
| E5067 | Belir Capital AG | 724500PEM92TFIBH3E89 | DE | CORP | E5063 | RATINGS |
| E5071 | Belir Chemicals SA | 724500EPR0DH4ZXK1N07 | FR | CORP | E5066 | RATINGS |
| E5080 | Belir Foods AG | 815600W19TGJNKXFFO22 | DE | CORP | E5072 | RATINGS |
| E5075 | Belir Gitid Industries plc | 815600DW5IX6LC8W8V29 | GB | CORP | E5068 | RATINGS |
| E5059 | Belir Group AG | 969500YPO4CFVEL1XX12 | DE | CORP | | RATINGS |
| E5063 | Belir Harem Property AG | 391200DIHCC3BA4VZZ12 | DE | CORP | E5060 | RATINGS |
| E5064 | Belir Holdings plc | 724500Q0JKSMWBXVBU93 | GB | CORP | E5061 | RATINGS |
| E5074 | Belir Industries plc | 549300KXQ2S560AVV453 | GB | CORP | E5068 | RATINGS |
| E5072 | Belir Katin Telecom AG | 815600R2EBVJ16RD3A20 | DE | CORP | E5067 | RATINGS |
| E5068 | Belir Kator Energy plc | 969500LH6R0LMYUZA394 | GB | CORP | E5064 | RATINGS |
| E5084 | Belir Luton Media SA | 815600NALYO1JPB0Y303 | FR | BANK | E5076 | RATINGS |
| E5077 | Belir Media SA | 213800PX54IYKA21SV31 | FR | CORP | E5069 | RATINGS |
| E5062 | Belir Mining SA | 54930011OTFCAUKB0A28 | FR | CORP | E5060 | RATINGS |
| E5065 | Belir Nelad Property AG | 549300L03V06VLA93J12 | DE | CORP | E5061 | RATINGS |
| E5076 | Belir Property SA | 96950092K7EM4MPGLP04 | FR | CORP | E5069 | RATINGS |
| E5073 | Belir Puvir Mining plc | 549300Z4E2ZBV3ZWA751 | GB | CORP | E5067 | RATINGS |
| E5060 | Belir Retail AG | 549300PQXT9OXKZVXP03 | DE | CORP | E5059 | RATINGS |
| E5070 | Belir Rusin Media SA | 8156004IQIH39FK9VH78 | FR | CORP | E5066 | RATINGS |
| E5085 | Belir Rutel Water SA | 213800K6R3NB1ZT7Y709 | CV | CORP | E5077 | RATINGS |
| E5066 | Belir Shipping SA | 2138006F3FLNO4C1FU85 | FR | CORP | E5062 | RATINGS |
| E5079 | Belir Sitom Logistics SA | 213800N76YAEEVTGC136 | FR | CORP | E5071 | RATINGS |
| E5061 | Belir Steel Inc | 5493004QWM1AN9Q59M90 | US | BANK | E5059 | RATINGS |
| E5078 | Belir Vasin Water plc | 969500OGDTR8B14SH139 | GB | BANK | E5070 | RATINGS |
| E5081 | Belir Vusad Telecom SA | 549300C58DC34KK7FK00 | VD | CORP | E5073 | RATINGS |
| E5069 | Belir Water SA | 391200PZ4I0VQJK2W457 | FR | CORP | E5065 | RATINGS |
| E1335 | Belor Telecom Finance plc | 9695001Q1J0GREF1Y798 | NL | FINSUB | E1234 | RATINGS |
| E1234 | Belor Telecom SpA | 815600HZK0IK4Q5GF769 | IT | CORP | | RATINGS |
| E1159 | Benem Property AG | 213800VMJXKPLM9ZIL74 | DE | BANK | | RATINGS |
| E1105 | Betin Pharma SA | 3912002RB0IGZZN6RN49 | GR | CORP | | RATINGS |
| E1288 | Binod Foods AG | 213800QEX3DTCPW3E621 | DE | BANK | | RATINGS |
| E1340 | Biram Steel plc | 213800CSTQH7UO0A8E29 | GB | CORP | | QA |
| E1351 | Bisad Property plc | 969500MERFFSB2CHQE09 | GB | CORP | | QA |
| E1322 | Bivid Mining SA | 7245003MRSQ8C823Z590 | FR | CORP | | RATINGS |
| E1343 | Bolem Energy plc | 969500F1DAQZF8FNJS41 | GB | CORP | | QA |
| E1191 | Boler Steel SA | 815600G5CMC2QEQUCG23 | FR | CORP | E1177 | RATINGS |
| E1135 | Bosar Retail plc | 549300C138N2A3615Y70 | GB | BANK | | RATINGS |
| E1242 | Botin Logistics SpA | 213800VNDQV0VN6FVU72 | IT | BANK | | RATINGS |
| E16 | Brindle Capital Ltd | 5493003Z3PXXR7KNFM81 | GB | CORP | | QA |
| E1010 | Buvir Industries Inc | 3912004R2GZJL49URX69 | US | CORP | | RATINGS |
| E5167 | CERID CHEMICALS SA | 391200B1GR4AGTV5WY99 | VD | CORP | | RESEARCH |
| E1180 | COTAN FOODS SA | 391200USHZVHBK9FHP01 | IT | CORP | | RESEARCH |
| E1112 | Calem Logistics Inc | 969500QJ1AV6AZJSB088 | US | CORP | | RATINGS |
| E1305 | Cenin Media SA | 724500OHVHFTDDP42261 | FR | CORP | | RATINGS |
| E5008 | Cerid Airlines BV | 815600M8RE9386DDQB31 | NL | CORP | E5003 | RATINGS |
| E5051 | Cerid Butad Capital SA | 969500P4S8FH9839YS39 | FR | CORP | E5039 | RATINGS |
| E5019 | Cerid Buvom Mining plc | 2138002W9KTVILKQ8Q89 | GB | CORP | E5009 | RATINGS |
| E5036 | Cerid Calin Energy SpA | 549300RJ7KMPDJVQY167 | IT | CORP | E5024 | RATINGS |
| E5056 | Cerid Capital plc | 391200Q0XXMZJQSOR362 | GB | CORP | E5044 | RATINGS |
| E5005 | Cerid Chemicals SA | 391200B1GR4AGTV5WY99 | VD | CORP | E5002 | RATINGS |
| E5058 | Cerid Cirad Industries BV | 391200XLOZO7S6T1FI61 | NL | BANK | E5046 | RATINGS |
| E5045 | Cerid Curel Water SA | 7245006QVOPQQK3JUP45 | CV | CORP | E5033 | RATINGS |
| E5023 | Cerid Dilal Utilities SA | 549300MXQ7UU7852PG70 | VD | CORP | E5011 | RATINGS |
| E5041 | Cerid Dolem Mining AG | 391200FXD4CH3FVZ4165 | DE | BANK | E5029 | RATINGS |
(480 more rows not shown)
Query 2:
| instrument_id | description | issuer_id | guarantor_id | seniority | currency | maturity |
|---|---|---|---|---|---|---|
| I02 | Kestrel Energy 6.25% notes due 2031 | E01 | | SUB | GBP | 2031-09-30 |
| I01 | Kestrel Energy 4.50% notes due 2030 | E01 | | SU | GBP | 2030-03-15 |
| 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 |
| I07 | Valdoria Telecom 4.25% notes due 2027 | E05 | | SU | XVD | 2027-08-31 |
| 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 |
| I05 | Halden Leasing 2.90% notes due 2028 | E11 | E10 | SU | EUR | 2028-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 |
| I1053 | Piran Logistics 7.25% notes due 2034 | E1190 | | SU | EUR | 2028-06-30 |
| I1054 | Lenam Industries 2.50% notes due 2036 | E1195 | | SU | GBP | 2030-06-30 |
(62 more rows not shown)
Run more queries, or give the final answers.The model
<invoke name="sql">
SELECT * FROM entities WHERE entity_id IN ('E01','E02','E03','E04','E05','E06','E07','E08','E09','E10','E11','E12','E13','E14','E15','E16','E17','E18','E19','E20','E21','E22','E23','E24','E25') OR regexp_matches(entity_id,'^E[0-9]{2}$') ORDER BY entity_id;
</invoke>
```sql
SELECT * FROM entities WHERE regexp_matches(entity_id,'^E[0-9]{2}$') ORDER BY entity_id;
```
```sql
SELECT * FROM instruments WHERE regexp_matches(instrument_id,'^I[0-9]{2}$') OR guarantor_id IS NOT NULL AND guarantor_id<>'' ORDER BY instrument_id;
```
```sql
SELECT * FROM rating_actions WHERE regexp_matches(rated_id,'^(E[0-9]{2}|I[0-9]{2})$') ORDER BY rated_id, rating_type, ccy_basis, date;
```Query results
Query 1:
| entity_id | name | lei | country | entity_type | parent_id | source_system |
|---|---|---|---|---|---|---|
| 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 |
| 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 |
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 |
| 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 3:
| action_id | date | rated_id | rating_type | ccy_basis | action | rating | outlook | watch | comment |
|---|---|---|---|---|---|---|---|---|---|
| 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 | | |
| A14 | 2025-04-01 | E05 | LTIDR | FC | AS | BB | STA | | |
| A13 | 2025-04-01 | E05 | LTIDR | LC | AS | BBB- | 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 | | | |
| 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 | | |
| 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 | | |
| A41 | 2024-03-01 | E15 | LTIDR | FC | AS | A | STA | | |
| A40 | 2024-03-01 | E15 | LTIDR | LC | AS | A+ | STA | | |
| A43 | 2024-04-01 | E16 | LTIDR | FC | AS | BBB- | STA | | |
| A44 | 2026-06-01 | E16 | LTIDR | FC | DG | BB+ | 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 4:
| entity_id | name | lei | country | entity_type | parent_id | source_system |
|---|---|---|---|---|---|---|
| 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 |
| 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 |
Run more queries, or give the final answers.The model
```sql
SELECT * FROM entities WHERE entity_type='SOV' OR source_system<>'RATINGS' ORDER BY lei, entity_id;
```
```sql
SELECT * FROM rating_actions WHERE rating_type='CC' OR rated_id IN (SELECT entity_id FROM entities WHERE entity_type='SOV') ORDER BY rated_id, date;
```
```sql
SELECT rating_type, ccy_basis, action, watch, outlook, count(*) n FROM rating_actions GROUP BY ALL ORDER BY ALL;
```
```sql
SELECT lei, count(*) n, string_agg(entity_id||':'||source_system||':'||country, ', ') recs FROM entities WHERE lei<>'' GROUP BY lei HAVING count(*)>1 ORDER BY lei;
```Query results
Query 1:
| entity_id | name | lei | country | entity_type | parent_id | source_system |
|---|---|---|---|---|---|---|
| E1340 | Biram Steel plc | 213800CSTQH7UO0A8E29 | GB | CORP | | QA |
| E1350 | Palol Airlines plc | 213800GZMC02BI2WJX12 | GB | CORP | | QA |
| E03 | NORTHWIND HLDGS | 213800PHEIYNJMHTDV74 | GB | CORP | | RESEARCH |
| E1002 | TUNOD STEEL SA | 3912003R00FP6CNV6210 | FR | CORP | | RESEARCH |
| E5167 | CERID CHEMICALS SA | 391200B1GR4AGTV5WY99 | VD | CORP | | RESEARCH |
| E1148 | DAREN MINING SA | 391200E9TAHDZV7CY568 | FR | CORP | | RESEARCH |
| E1117 | HENER ENERGY | 391200JN4T4KY2HCRU75 | GB | CORP | | RESEARCH |
| E1022 | NINER PHARMA | 391200KLG6G4KVIMIU52 | GB | CORP | | RESEARCH |
| E1346 | Kalem Property AG | 391200MMTFNAN4NBM054 | DE | CORP | | QA |
| E17 | HALDEN BANK | 391200QYPVFF2O9K2039 | LU | BANK | | RESEARCH |
| E1345 | Wesen Retail plc | 391200T3GEO5X4SJMO02 | GB | CORP | | QA |
| E1180 | COTAN FOODS SA | 391200USHZVHBK9FHP01 | IT | CORP | | RESEARCH |
| E5168 | BELIR MINING SA | 54930011OTFCAUKB0A28 | FR | CORP | E5086 | RESEARCH |
| E16 | Brindle Capital Ltd | 5493003Z3PXXR7KNFM81 | GB | CORP | | QA |
| E1239 | WEVIN CAPITAL SA | 5493004IM0PRT8BSDK29 | GR | CORP | | RESEARCH |
| E1214 | WINIM MINING SA | 549300A64I73OEIC4R87 | NL | CORP | | RESEARCH |
| E1060 | KELIM MEDIA SA | 549300CRXZL5I1OT6L14 | CV | CORP | | RESEARCH |
| E1153 | KIVEL PROPERTY | 549300E50JHDJNBUGF22 | GB | CORP | | RESEARCH |
| E1262 | MUNAM WATER SA | 549300H1N0EQEAZLE362 | ES | CORP | | RESEARCH |
| E1210 | MALID MINING SPA | 549300HWTXXHJP2HKU38 | DE | CORP | | RESEARCH |
| E1341 | Panar Airlines SA | 549300IFOJRHYHEP5N72 | FR | CORP | | QA |
| E1097 | RAVON CAPITAL SA | 549300NTCTGRKRYIAN83 | CV | CORP | | RESEARCH |
| E1170 | SEREN TELECOM | 549300XV49ES64RGNQ00 | GB | CORP | | RESEARCH |
| E1342 | Cuvol Water AG | 7245000RRKYSQSJ2DB31 | DE | CORP | | QA |
| E1347 | Nunan Capital plc | 724500649FYULZG25F44 | GB | CORP | | QA |
| E1139 | KONEL ENERGY BV | 724500BSV4X2J7KUR535 | NL | CORP | | RESEARCH |
| E1348 | Wosed Holdings AG | 724500JEL6C1PJZEDM26 | DE | CORP | | QA |
| E1344 | Naled Utilities plc | 724500N069ZCQGY1UI76 | GB | CORP | | QA |
| E1349 | Parod Pharma SA | 724500PGN9P0AMIWNV47 | FR | CORP | | QA |
| E1319 | SUTEM WATER | 724500UQKUINIUB80J18 | GB | CORP | | RESEARCH |
| E1259 | NIRAD RETAIL SA | 724500YEJSJ19G17TW94 | FR | BANK | | RESEARCH |
| E5170 | Hetar Test plc | 8156005EHMOKQENUED17 | VD | CORP | E5001 | QA |
| E1030 | LESON TELECOM INC | 8156008DPX4I9DNKWN26 | US | BANK | | RESEARCH |
| E1104 | VAVAM PHARMA INC | 815600HDI8Y3IWGOOH22 | US | CORP | | RESEARCH |
| E1246 | GATER HOLDINGS SA | 815600LRX1P8142NMF42 | FR | CORP | | RESEARCH |
| E1299 | FANER STEEL SA | 815600RCZP0ISY44E024 | ES | CORP | | RESEARCH |
| E1311 | NATIL RETAIL SPA | 9695000PSF2HLPO9AE57 | IT | BANK | | RESEARCH |
| E1343 | Bolem Energy plc | 969500F1DAQZF8FNJS41 | GB | CORP | | QA |
| E1157 | RUVEN AIRLINES | 969500KYKHRI6N2WRN19 | US | CORP | | RESEARCH |
| E1351 | Bisad Property plc | 969500MERFFSB2CHQE09 | GB | CORP | | QA |
| E1161 | DILED STEEL SA | 969500PM41NS2PBZU440 | FR | CORP | | RESEARCH |
| E1254 | VUSIR TELECOM SA | 969500QXEZ0NSV6EIW69 | ES | BANK | | RESEARCH |
| E5169 | WONOD STEEL BV | 969500W1342GHBTOGH81 | VD | CORP | | RESEARCH |
| CV | Republic of Corvenia | | CV | SOV | | RATINGS |
| VD | Republic of Valdoria | | VD | SOV | | RATINGS |
Query 2:
| action_id | date | rated_id | rating_type | ccy_basis | action | rating | outlook | watch | comment |
|---|---|---|---|---|---|---|---|---|---|
| A37 | 2024-01-01 | CV | CC | | AS | A | | | |
| A38 | 2024-01-01 | CV | LTIDR | FC | AS | BBB+ | STA | | |
| A39 | 2024-01-01 | CV | LTIDR | LC | AS | A- | STA | | |
| A12 | 2025-04-01 | VD | CC | | AS | BB | | | |
Query 3:
| rating_type | ccy_basis | action | watch | outlook | n |
|---|---|---|---|---|---|
| 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 |
Query 4:
| lei | n | recs |
|---|---|---|
| 213800PHEIYNJMHTDV74 | 2 | E02:RATINGS:GB, E03:RESEARCH:GB |
| 3912003R00FP6CNV6210 | 2 | E1001:RATINGS:FR, E1002:RESEARCH:FR |
| 391200B1GR4AGTV5WY99 | 2 | E5005:RATINGS:VD, E5167:RESEARCH:VD |
| 391200E9TAHDZV7CY568 | 2 | E1147:RATINGS:FR, E1148:RESEARCH:FR |
| 391200JN4T4KY2HCRU75 | 2 | E1116:RATINGS:GB, E1117:RESEARCH:GB |
| 391200KLG6G4KVIMIU52 | 2 | E1021:RATINGS:GB, E1022:RESEARCH:GB |
| 391200QYPVFF2O9K2039 | 2 | E10:RATINGS:DE, E17:RESEARCH:LU |
| 391200USHZVHBK9FHP01 | 2 | E1179:RATINGS:ES, E1180:RESEARCH:IT |
| 54930011OTFCAUKB0A28 | 2 | E5062:RATINGS:FR, E5168:RESEARCH:FR |
| 5493004IM0PRT8BSDK29 | 2 | E1238:RATINGS:GR, E1239:RESEARCH:GR |
| 549300A64I73OEIC4R87 | 2 | E1213:RATINGS:FR, E1214:RESEARCH:NL |
| 549300CRXZL5I1OT6L14 | 2 | E1059:RATINGS:CV, E1060:RESEARCH:CV |
| 549300E50JHDJNBUGF22 | 2 | E1152:RATINGS:GB, E1153:RESEARCH:GB |
| 549300H1N0EQEAZLE362 | 2 | E1261:RATINGS:ES, E1262:RESEARCH:ES |
| 549300HWTXXHJP2HKU38 | 2 | E1209:RATINGS:IT, E1210:RESEARCH:DE |
| 549300NTCTGRKRYIAN83 | 2 | E1096:RATINGS:CV, E1097:RESEARCH:CV |
| 549300XV49ES64RGNQ00 | 2 | E1169:RATINGS:GB, E1170:RESEARCH:GB |
| 724500BSV4X2J7KUR535 | 2 | E1138:RATINGS:NL, E1139:RESEARCH:NL |
| 724500UQKUINIUB80J18 | 2 | E1318:RATINGS:GB, E1319:RESEARCH:GB |
| 724500YEJSJ19G17TW94 | 2 | E1258:RATINGS:FR, E1259:RESEARCH:FR |
| 8156008DPX4I9DNKWN26 | 2 | E1029:RATINGS:US, E1030:RESEARCH:US |
| 815600HDI8Y3IWGOOH22 | 2 | E1103:RATINGS:US, E1104:RESEARCH:US |
| 815600LRX1P8142NMF42 | 2 | E1245:RATINGS:CV, E1246:RESEARCH:FR |
| 815600RCZP0ISY44E024 | 2 | E1298:RATINGS:ES, E1299:RESEARCH:ES |
| 9695000PSF2HLPO9AE57 | 2 | E1310:RATINGS:IT, E1311:RESEARCH:IT |
| 969500KYKHRI6N2WRN19 | 2 | E1156:RATINGS:DE, E1157:RESEARCH:US |
| 969500PM41NS2PBZU440 | 2 | E1160:RATINGS:FR, E1161:RESEARCH:FR |
| 969500QXEZ0NSV6EIW69 | 2 | E1253:RATINGS:ES, E1254:RESEARCH:ES |
| 969500W1342GHBTOGH81 | 2 | E5106:RATINGS:NL, E5169:RESEARCH:VD |
Run more queries, or give the final answers.The model
Building working views first: entities merged by LEI, QA records excluded, RESEARCH country taking precedence.
```sql
CREATE OR REPLACE VIEW ek AS SELECT entity_id, coalesce(nullif(lei,''),entity_id) k, name, country, entity_type, nullif(parent_id,'') parent_id, source_system FROM entities WHERE source_system<>'QA';
CREATE OR REPLACE VIEW ent AS SELECT k, coalesce(max(name) filter(where source_system='RATINGS'), max(name)) name, coalesce(max(country) filter(where source_system='RESEARCH'), max(country)) country, max(entity_type) entity_type, coalesce(max(parent_id) filter(where source_system='RATINGS'), max(parent_id)) pid, coalesce(min(entity_id) filter(where source_system='RATINGS'), min(entity_id)) rep FROM ek GROUP BY k;
CREATE OR REPLACE VIEW par AS SELECT e.k, e.rep, e.name, e.country, e.entity_type, p.k pk FROM ent e LEFT JOIN ek p ON p.entity_id=e.pid;
CREATE OR REPLACE VIEW grp AS WITH RECURSIVE r(k, root, depth) AS (SELECT k,k,0 FROM par WHERE pk IS NULL UNION ALL SELECT p.k, r.root, r.depth+1 FROM par p JOIN r ON p.pk=r.k) SELECT * FROM r;
CREATE OR REPLACE VIEW act AS SELECT a.*, ek.k FROM rating_actions a JOIN ek ON ek.entity_id=a.rated_id;
CREATE OR REPLACE VIEW st AS SELECT * FROM (SELECT k, rating_type, ccy_basis, date, action, rating, outlook, watch, row_number() over (partition by k,rating_type,ccy_basis order by date desc, action_id desc) rn FROM act WHERE date<='2026-10-01' AND rating_type IN ('LTIDR','STIDR')) WHERE rn=1;
SELECT (SELECT count(*) FROM ent) n_ent, (SELECT count(*) FROM grp) n_grp, (SELECT count(*) FROM par) n_par;
```
```sql
SELECT g.root, r.rep, r.name, count(*) n, max(g.depth) maxd, count(*) filter(where g.depth=3) d3 FROM grp g JOIN ent r ON r.k=g.root GROUP BY ALL HAVING count(*)>1 ORDER BY n DESC;
```
```sql
SELECT 'LU' x, string_agg(rep,',') FROM ent WHERE country='LU'
UNION ALL SELECT 'default_ever', string_agg(DISTINCT e.rep,',') FROM act a JOIN ent e ON e.k=a.k WHERE a.rating_type IN ('LTIDR','STIDR') AND a.rating IN ('RD','D')
UNION ALL SELECT 'default_1Oct', string_agg(DISTINCT e.rep,',') FROM st s JOIN ent e ON e.k=s.k WHERE s.rating IN ('RD','D')
UNION ALL SELECT 'issuers_rated', count(DISTINCT k)::varchar FROM st WHERE rating_type='LTIDR' AND rating<>'WD'
UNION ALL SELECT 'GB_rated', count(DISTINCT s.k)::varchar FROM st s JOIN ent e ON e.k=s.k WHERE rating_type='LTIDR' AND rating<>'WD' AND e.country='GB'
UNION ALL SELECT 'RWN', string_agg(DISTINCT e.rep,',') FROM st s JOIN ent e ON e.k=s.k WHERE rating_type='LTIDR' AND watch='RWN' AND rating<>'WD'
UNION ALL SELECT 'NEG', string_agg(DISTINCT e.rep,',') FROM st s JOIN ent e ON e.k=s.k WHERE rating_type='LTIDR' AND outlook='NEG' AND rating<>'WD'
UNION ALL SELECT 'lost', string_agg(DISTINCT e.rep,',') FROM (SELECT DISTINCT k FROM act WHERE rating_type='LTIDR' AND action<>'WD') h JOIN ent e ON e.k=h.k WHERE NOT EXISTS (SELECT 1 FROM st s WHERE s.k=h.k AND s.rating_type='LTIDR' AND s.rating<>'WD')
UNION ALL SELECT 'DG2026', string_agg(DISTINCT e.rep,',') FROM act a JOIN ent e ON e.k=a.k WHERE a.rating_type='LTIDR' AND a.action='DG' AND a.date BETWEEN '2026-01-01' AND '2026-12-31'
UNION ALL SELECT 'future', count(*)::varchar FROM rating_actions WHERE date>'2026-10-01';
```Query results
Query 1 failed: Parser Error: syntax error at or near "name"
Query 2 failed: Catalog Error: Table with name grp does not exist!
Query 3 failed: Catalog Error: Table with name ent does not exist!
Run more queries, or give the final answers.The model
Aliasing `name` without `AS` caused the parse error, so I'm rebuilding the views with explicit aliases.
```sql
CREATE OR REPLACE VIEW ek AS SELECT entity_id, coalesce(nullif(lei,''),entity_id) AS k, name AS nm, country, entity_type, nullif(parent_id,'') AS parent_id, source_system FROM entities WHERE source_system<>'QA';
CREATE OR REPLACE VIEW ent AS SELECT k, coalesce(max(nm) filter(where source_system='RATINGS'), max(nm)) AS nm, coalesce(max(country) filter(where source_system='RESEARCH'), max(country)) AS country, max(entity_type) AS entity_type, coalesce(max(parent_id) filter(where source_system='RATINGS'), max(parent_id)) AS pid, coalesce(min(entity_id) filter(where source_system='RATINGS'), min(entity_id)) AS rep FROM ek GROUP BY k;
CREATE OR REPLACE VIEW par AS SELECT e.k, e.rep, e.nm, e.country, e.entity_type, p.k AS pk FROM ent e LEFT JOIN ek p ON p.entity_id=e.pid;
CREATE OR REPLACE VIEW grp AS WITH RECURSIVE r(k, root, depth) AS (SELECT k,k,0 FROM par WHERE pk IS NULL UNION ALL SELECT p.k, r.root, r.depth+1 FROM par p JOIN r ON p.pk=r.k) SELECT * FROM r;
CREATE OR REPLACE VIEW act AS SELECT a.*, ek.k FROM rating_actions a JOIN ek ON ek.entity_id=a.rated_id;
CREATE OR REPLACE VIEW st AS SELECT * FROM (SELECT k, rating_type, ccy_basis, date, action, rating, outlook, watch, row_number() over (partition by k,rating_type,ccy_basis order by date desc, action_id desc) AS rn FROM act WHERE date<='2026-10-01' AND rating_type IN ('LTIDR','STIDR')) WHERE rn=1;
SELECT (SELECT count(*) FROM ent) n_ent, (SELECT count(*) FROM grp) n_grp, (SELECT count(*) FROM par) n_par;
```
```sql
SELECT g.root, r.rep, r.nm, count(*) n, max(g.depth) maxd, count(*) filter(where g.depth=3) d3 FROM grp g JOIN ent r ON r.k=g.root GROUP BY ALL HAVING count(*)>1 ORDER BY n DESC;
```
```sql
SELECT 'LU' x, string_agg(rep,',') v FROM ent WHERE country='LU'
UNION ALL SELECT 'default_ever', string_agg(DISTINCT e.rep,',') FROM act a JOIN ent e ON e.k=a.k WHERE a.rating_type IN ('LTIDR','STIDR') AND a.rating IN ('RD','D')
UNION ALL SELECT 'default_1Oct', string_agg(DISTINCT e.rep,',') FROM st s JOIN ent e ON e.k=s.k WHERE s.rating IN ('RD','D')
UNION ALL SELECT 'issuers_rated', count(DISTINCT k)::varchar FROM st WHERE rating_type='LTIDR' AND rating<>'WD'
UNION ALL SELECT 'GB_rated', count(DISTINCT s.k)::varchar FROM st s JOIN ent e ON e.k=s.k WHERE rating_type='LTIDR' AND rating<>'WD' AND e.country='GB'
UNION ALL SELECT 'RWN', string_agg(DISTINCT e.rep,',') FROM st s JOIN ent e ON e.k=s.k WHERE rating_type='LTIDR' AND watch='RWN' AND rating<>'WD'
UNION ALL SELECT 'NEG', string_agg(DISTINCT e.rep,',') FROM st s JOIN ent e ON e.k=s.k WHERE rating_type='LTIDR' AND outlook='NEG' AND rating<>'WD'
UNION ALL SELECT 'lost', string_agg(DISTINCT e.rep,',') FROM (SELECT DISTINCT k FROM act WHERE rating_type='LTIDR' AND action<>'WD') h JOIN ent e ON e.k=h.k WHERE NOT EXISTS (SELECT 1 FROM st s WHERE s.k=h.k AND s.rating_type='LTIDR' AND s.rating<>'WD')
UNION ALL SELECT 'DG2026', string_agg(DISTINCT e.rep,',') FROM act a JOIN ent e ON e.k=a.k WHERE a.rating_type='LTIDR' AND a.action='DG' AND a.date BETWEEN '2026-01-01' AND '2026-12-31'
UNION ALL SELECT 'future', count(*)::varchar FROM rating_actions WHERE date>'2026-10-01';
```Query results
Query 1:
| n_ent | n_grp | n_par |
|---|---|---|
| 497 | 497 | 497 |
Query 2:
| root | rep | nm | n | maxd | d3 |
|---|---|---|---|---|---|
| 815600F48PANJQE75352 | E5001 | Cerid Group plc | 58 | 6 | 12 |
| 969500YPO4CFVEL1XX12 | E5059 | Belir Group AG | 27 | 5 | 4 |
| 7245003GC3MAPLM74H56 | E5105 | Wonod Group SA | 27 | 5 | 6 |
| 8156002XDJU2OFI9JC47 | E5145 | Geren Group SA | 22 | 4 | 6 |
| 213800PJV1XFQEKJ1L86 | E5086 | Rotam Group Inc | 19 | 4 | 6 |
| 724500QJUUI5LKTI3C20 | E5132 | Vesol Group BV | 13 | 4 | 4 |
| 969500IBYK0X2ZT52780 | E1004 | Munem Retail SA | 6 | 2 | 0 |
| 3912006TI0YGHZXX0R89 | E1074 | Kuron Steel plc | 3 | 1 | 0 |
| 213800CG5LUFZKTQXL65 | E1071 | Mored Utilities SA | 3 | 1 | 0 |
| 9695003FBHLB9KIKNT76 | E1063 | Kotom Media SA | 3 | 1 | 0 |
| 815600JRN7AOE36KFR35 | E1005 | Setan Airlines Inc | 3 | 2 | 0 |
| 391200OKDLRW7OVOQO93 | E1073 | Hivor Industries Inc | 3 | 1 | 0 |
| 2138007MIV2OS05PET94 | E1025 | Tulol Shipping SA | 3 | 1 | 0 |
| 3912004R2GZJL49URX69 | E1010 | Buvir Industries Inc | 3 | 2 | 0 |
| 815600ASM9EHDG931T89 | E09 | Halden Group plc | 3 | 2 | 0 |
| 8156008Z86BWAKVE7I73 | E1166 | Ranim Shipping Inc | 2 | 1 | 0 |
| 549300FCSHHELSCZX562 | E1020 | Finel Media AG | 2 | 1 | 0 |
| 213800AYN5M70T4RZ707 | E1162 | Wunam Telecom BV | 2 | 1 | 0 |
| 39120035C3L494GPV335 | E1107 | Warod Capital SA | 2 | 1 | 0 |
| 969500C8XYHXZBFMUO41 | E1026 | Vunam Water BV | 2 | 1 | 0 |
| 815600LDQIUCNNTOL286 | E1278 | Bavil Chemicals plc | 2 | 1 | 0 |
| 815600K08Z108WT4MF26 | E1198 | Kiver Property AG | 2 | 1 | 0 |
| 213800PHEIYNJMHTDV74 | E02 | Northwind Holdings plc | 2 | 1 | 0 |
| 391200MB5QFXCD5X8I15 | E1084 | Poval Chemicals SA | 2 | 1 | 0 |
| 815600HZK0IK4Q5GF769 | E1234 | Belor Telecom SpA | 2 | 1 | 0 |
| 969500T86HNH5S920X18 | E1027 | Tesad Media Inc | 2 | 1 | 0 |
| 213800KNUYRFXEU6PS61 | E1068 | Sanin Mining SA | 2 | 1 | 0 |
| 549300EZ4HXP0L5RAZ01 | E1038 | Lanon Telecom BV | 2 | 1 | 0 |
| 391200KLG6G4KVIMIU52 | E1021 | Niner Pharma plc | 2 | 1 | 0 |
| 969500SQSSYT8HOYOP58 | E1244 | Palad Mining Inc | 2 | 1 | 0 |
| 549300EK7E9K0SBA9583 | E1189 | Divid Property plc | 2 | 1 | 0 |
| 549300GV9F3CNKP0QJ18 | E1069 | Ganen Shipping SA | 2 | 1 | 0 |
| 815600JMC4KYXP7JLQ54 | E1082 | Gilen Capital Inc | 2 | 1 | 0 |
| 815600GT61BFNLDX4741 | E1241 | Wivin Airlines SA | 2 | 1 | 0 |
| 969500D8VQO3X7NDHQ76 | E1260 | Votim Industries Inc | 2 | 1 | 0 |
| 3912006FHXTH5V6WNK07 | E1023 | Heled Water plc | 2 | 1 | 0 |
| 213800OK3464E1I8MT49 | E1083 | Senir Mining plc | 2 | 1 | 0 |
| 815600JSNIJ4UFCBF662 | E1015 | Civen Steel Inc | 2 | 1 | 0 |
| 5493002BLV266QJVIH90 | E1061 | Dotan Retail AG | 2 | 1 | 0 |
| 815600NRZ5OBW078A263 | E1078 | Menir Shipping Inc | 2 | 1 | 0 |
| 213800ENVP6736MREW83 | E1052 | Witad Steel SA | 2 | 1 | 0 |
| 8156009KMEPDX5HOT275 | E1176 | Navor Holdings plc | 2 | 1 | 0 |
| 815600N2UAHQREHHWF76 | E1007 | Golod Property plc | 2 | 1 | 0 |
| 5493007DOMNBIWQWGR68 | E1119 | Nuner Holdings SpA | 2 | 1 | 0 |
Query 3:
| x | v |
|---|---|
| LU | E10 |
| default_ever | E08 |
| default_1Oct | E08 |
| issuers_rated | 377 |
| GB_rated | 79 |
| RWN | E1013,E1297,E1238,E1061,E1317,E1242,E1037,E1209,E1181,E1133,E06,E1194,E1088,E1098,E1126,E1019,E1006,E1264,E1146,E1203,E1066,E1314,E1323,E1168,E1109,E1267,E1059,E1266,E1039,E1099,E1132,E1260 |
| NEG | E1080,E1005,E5116,E1046,E1034,E1188,E5057,E1248,E5073,E5099,E1263,E1228,E5050,E1064,E1261,E01,E1118,E5020,E1029,E5059,E1160,E5019,E5113,E1211,E5131,E09,E1158,E1105,E1079,E1055,E1294,E5119,E5141,E1271,E1190,E1072,E5156,E5039,E1300,E5102,E5097,E1059,E5062,E5013,E5023,E1056,E1282 |
| lost | E1218,E1316,E1244,E1234,E1233,E1200,E1225,E1076,E1057,E1155,E1308,E1253,E1032,E1159,E1007,E1062,E1277,E1219,E1206,E1320,E1001,E1124,E1172,E1048,E1084,E1021,E07,E1166,E1041,E1138,E1063,E1107,E1140,E1205,E1121 |
| DG2026 | E1294,E1151,E1034,E1213,E1300,E1163,E5097,E5019,E5113,E1159,E1057,E1053,E1144,E1243,E1229,E1307,E5033,E1255,E1263,E1228,E1298,E1080,E5116,E1186,E1112,E1169,E08,E1285,E1290,E1064,E1093,E1051,E1058,E1167,E5156,E10,E5059,E1160 |
| future | 8 |
Run more queries, or give the final answers.The model
<invoke name="sql">
<parameter name="query">CREATE OR REPLACE VIEW anc AS WITH RECURSIVE a(k, ak, dist) AS (SELECT k, pk, 1 FROM par WHERE pk IS NOT NULL UNION ALL SELECT a.k, p.pk, a.dist+1 FROM a JOIN par p ON p.k=a.ak WHERE p.pk IS NOT NULL) SELECT * FROM a;
CREATE OR REPLACE VIEW sc AS SELECT * FROM (VALUES ('AAA',1),('AA+',2),('AA',3),('AA-',4),('A+',5),('A',6),('A-',7),('BBB+',8),('BBB',9),('BBB-',10),('BB+',11),('BB',12),('BB-',13),('B+',14),('B',15),('B-',16),('CCC',17),('CC',18),('C',19),('RD',20),('D',21)) t(r,n);
CREATE OR REPLACE VIEW fc AS SELECT s.k, s.rating FROM st s WHERE rating_type='LTIDR' AND ccy_basis='FC' AND rating<>'WD';
SELECT 'Q25_48', count(*) filter(where n<=10)||'/'||count(*) FROM (SELECT i.instrument_id, (SELECT rating FROM rating_actions a WHERE a.rated_id=i.instrument_id AND a.rating_type='INST' AND a.action<>'EX' AND a.date<='2026-10-01' ORDER BY date desc, action_id desc LIMIT 1) r FROM instruments i JOIN ek ON ek.entity_id=i.issuer_id) x LEFT JOIN sc ON sc.r=x.r WHERE x.r IS NOT NULL AND x.r<>'WD'
UNION ALL SELECT 'Q30', string_agg(e.rep,',') FROM fc JOIN ent e ON e.k=fc.k JOIN (SELECT rated_id c, rating cc FROM rating_actions WHERE rating_type='CC') c ON c.c=e.country WHERE fc.rating=c.cc AND e.entity_type<>'SOV'
UNION ALL SELECT 'Q31', string_agg(e.rep||':'||fc.rating,',') FROM fc JOIN ent e ON e.k=fc.k JOIN (SELECT rated_id c, rating cc FROM rating_actions WHERE rating_type='CC') c ON c.c=e.country JOIN sc a ON a.r=fc.rating JOIN sc b ON b.r=c.cc WHERE a.n<b.n AND e.entity_type<>'SOV'
UNION ALL SELECT 'Q49_50', (SELECT string_agg(r.rep||':'||g.depth,',') FROM grp g JOIN ent x ON x.k=g.k JOIN ent r ON r.k=g.root WHERE x.nm ILIKE 'Cerid Rosor Holdings%')
UNION ALL SELECT 'Q54', (SELECT string_agg(x.rep,',') FROM grp g JOIN ent x ON x.k=g.k WHERE g.root=(SELECT k FROM ent WHERE nm='Wonod Group SA') AND x.country='VD')
UNION ALL SELECT 'Q55', (SELECT count(DISTINCT s.k)::varchar FROM st s JOIN anc a ON a.k=s.k JOIN ent p ON p.k=a.ak WHERE s.rating_type='LTIDR' AND s.rating<>'WD' AND p.country='VD')
UNION ALL SELECT 'Q56', (SELECT string_agg(x.rep||':'||fc.rating,',') FROM grp g JOIN fc ON fc.k=g.k JOIN ent x ON x.k=g.k WHERE g.root=(SELECT k FROM ent WHERE nm='Vesol Group BV'))
UNION ALL SELECT 'Q57', (SELECT string_agg(p.rep||':'||a1.dist||'/'||a2.dist,',') FROM ent e1 JOIN anc a1 ON a1.k=e1.k JOIN ent e2 ON e2.nm='Cerid Telecom SA' JOIN anc a2 ON a2.k=e2.k AND a2.ak=a1.ak JOIN ent p ON p.k=a1.ak WHERE e1.nm='Cerid Guven Energy SA')
UNION ALL SELECT 'Q58', (SELECT string_agg(DISTINCT gg.rep||'->'||i.instrument_id,',') FROM instruments i JOIN ek ie ON ie.entity_id=i.issuer_id JOIN ek ge ON ge.entity_id=i.guarantor_id JOIN grp gi ON gi.k=ie.k JOIN grp gg0 ON gg0.k=ge.k JOIN ent gg ON gg.k=ge.k WHERE gi.root<>gg0.root)
UNION ALL SELECT 'Q61', (SELECT count(*)::varchar||':'||string_agg(x.rep||fc.rating,',') FROM grp g JOIN fc ON fc.k=g.k JOIN ent x ON x.k=g.k JOIN sc ON sc.r=fc.rating WHERE g.root=(SELECT k FROM ent WHERE nm='Cerid Group plc') AND sc.n>10)
UNION ALL SELECT 'Q60', (SELECT string_agg(i.issuer_id||' g='||i.guarantor_id,',') FROM instruments i WHERE instrument_id='I5007')
UNION ALL SELECT 'Q5_33', (SELECT string_agg(DISTINCT rated_id||rating_type||date||rating,',') FROM rating_actions WHERE rated_id IN ('E5145','E10','E02','E5133','E5133'));</parameter>
</invoke>
```</parameter>
</invoke>
```
Oops, formatting; let me issue properly.
```sql
CREATE OR REPLACE VIEW anc AS WITH RECURSIVE a(k, ak, dist) AS (SELECT k, pk, 1 FROM par WHERE pk IS NOT NULL UNION ALL SELECT a.k, p.pk, a.dist+1 FROM a JOIN par p ON p.k=a.ak WHERE p.pk IS NOT NULL) SELECT * FROM a;
CREATE OR REPLACE VIEW sc AS SELECT * FROM (VALUES ('AAA',1),('AA+',2),('AA',3),('AA-',4),('A+',5),('A',6),('A-',7),('BBB+',8),('BBB',9),('BBB-',10),('BB+',11),('BB',12),('BB-',13),('B+',14),('B',15),('B-',16),('CCC',17),('CC',18),('C',19),('RD',20),('D',21)) t(r,n);
CREATE OR REPLACE VIEW fc AS SELECT s.k, s.rating FROM st s WHERE rating_type='LTIDR' AND ccy_basis='FC' AND rating<>'WD';
SELECT 'Q25_48' q, count(*) filter(where n<=10)||'/'||count(*) v FROM (SELECT i.instrument_id, (SELECT rating FROM rating_actions a WHERE a.rated_id=i.instrument_id AND a.rating_type='INST' AND a.action<>'EX' AND a.date<='2026-10-01' ORDER BY date desc, action_id desc LIMIT 1) r FROM instruments i JOIN ek ON ek.entity_id=i.issuer_id) x LEFT JOIN sc ON sc.r=x.r WHERE x.r IS NOT NULL AND x.r<>'WD'
UNION ALL SELECT 'Q30', string_agg(e.rep,',') FROM fc JOIN ent e ON e.k=fc.k JOIN (SELECT rated_id c, rating cc FROM rating_actions WHERE rating_type='CC') c ON c.c=e.country WHERE fc.rating=c.cc AND e.entity_type<>'SOV'
UNION ALL SELECT 'Q31', string_agg(e.rep||':'||fc.rating,',') FROM fc JOIN ent e ON e.k=fc.k JOIN (SELECT rated_id c, rating cc FROM rating_actions WHERE rating_type='CC') c ON c.c=e.country JOIN sc a ON a.r=fc.rating JOIN sc b ON b.r=c.cc WHERE a.n<b.n AND e.entity_type<>'SOV'
UNION ALL SELECT 'Q49_50', (SELECT string_agg(r.rep||':'||g.depth,',') FROM grp g JOIN ent x ON x.k=g.k JOIN ent r ON r.k=g.root WHERE x.nm ILIKE 'Cerid Rosor Holdings%')
UNION ALL SELECT 'Q54', (SELECT string_agg(x.rep,',') FROM grp g JOIN ent x ON x.k=g.k WHERE g.root=(SELECT k FROM ent WHERE nm='Wonod Group SA') AND x.country='VD')
UNION ALL SELECT 'Q55', (SELECT count(DISTINCT s.k)::varchar FROM st s JOIN anc a ON a.k=s.k JOIN ent p ON p.k=a.ak WHERE s.rating_type='LTIDR' AND s.rating<>'WD' AND p.country='VD')
UNION ALL SELECT 'Q56', (SELECT string_agg(x.rep||':'||fc.rating,',') FROM grp g JOIN fc ON fc.k=g.k JOIN ent x ON x.k=g.k WHERE g.root=(SELECT k FROM ent WHERE nm='Vesol Group BV'))
UNION ALL SELECT 'Q57', (SELECT string_agg(p.rep||':'||a1.dist||'/'||a2.dist,',') FROM ent e1 JOIN anc a1 ON a1.k=e1.k JOIN ent e2 ON e2.nm='Cerid Telecom SA' JOIN anc a2 ON a2.k=e2.k AND a2.ak=a1.ak JOIN ent p ON p.k=a1.ak WHERE e1.nm='Cerid Guven Energy SA')
UNION ALL SELECT 'Q58', (SELECT string_agg(DISTINCT ge.entity_id||'->'||i.instrument_id,',') FROM instruments i JOIN ek ie ON ie.entity_id=i.issuer_id JOIN ek ge ON ge.entity_id=i.guarantor_id JOIN grp gi ON gi.k=ie.k JOIN grp gg0 ON gg0.k=ge.k WHERE gi.root<>gg0.root)
UNION ALL SELECT 'Q61', (SELECT count(*)::varchar||':'||string_agg(x.rep||fc.rating,',') FROM grp g JOIN fc ON fc.k=g.k JOIN ent x ON x.k=g.k JOIN sc ON sc.r=fc.rating WHERE g.root=(SELECT k FROM ent WHERE nm='Cerid Group plc') AND sc.n>10)
UNION ALL SELECT 'Q60', (SELECT string_agg(i.issuer_id||' g='||i.guarantor_id,',') FROM instruments i WHERE instrument_id='I5007')
UNION ALL SELECT 'Q60b', (SELECT string_agg(rep||' root='||root,',') FROM (SELECT x.rep, g.root FROM grp g JOIN ent x ON x.k=g.k WHERE x.rep IN ('E5133','E5145')));
```Query results
Query 1:
| q | v |
|---|---|
| Q25_48 | 72/113 |
| Q30 | E5124,E5116,E5047,E1194,E5012,E15,E05,E1039,E5091,E1126,E1236,E1101,E1028 |
| Q31 | |
| Q49_50 | E5001:6 |
| Q54 | E5106,E5124,E5130 |
| Q55 | 31 |
| Q56 | E5132:BB+,E5133:BBB-,E5136:BBB-,E5140:A+,E5141:BB,E5143:A,E5144:BB- |
| Q57 | E5002:2/2,E5001:3/3 |
| Q58 | E5145->I5007 |
| Q61 | 19:E5029BB+,E5047BB,E5039BB-,E5037B+,E5030B,E5048B-,E5042BB,E5022BB-,E5021B,E5041B-,E5025BB,E5010BB-,E5007B,E5028B-,E5016BB,E5024B-,E5012BB,E5023B-,E5013B- |
| Q60 | E5133 g=E5145 |
| Q60b | E5145 root=8156002XDJU2OFI9JC47,E5133 root=724500QJUUI5LKTI3C20 |
Query 2:
| 'Q25_48' | ((count_star() FILTER (WHERE (n <= 10)) || '/') || count_star()) |
|---|---|
| Q25_48 | 72/113 |
| Q30 | E5047,E1194,E5124,E15,E1101,E1039,E1028,E5116,E5091,E1126,E1236,E5012,E05 |
| Q31 | |
| Q49_50 | E5001:6 |
| Q54 | E5106,E5124,E5130 |
| Q55 | 31 |
| Q56 | E5132:BB+,E5133:BBB-,E5136:BBB-,E5140:A+,E5141:BB,E5143:A,E5144:BB- |
| Q57 | E5002:2/2,E5001:3/3 |
| Q58 | E5145->I5007 |
| Q61 | 19:E5029BB+,E5047BB,E5039BB-,E5037B+,E5030B,E5048B-,E5042BB,E5022BB-,E5021B,E5041B-,E5025BB,E5010BB-,E5007B,E5028B-,E5016BB,E5024B-,E5012BB,E5023B-,E5013B- |
| Q60 | E5133 g=E5145 |
| Q5_33 | E10LTIDR2023-05-01A-,E02LTIDR2023-11-01A,E10LTIDR2026-04-15BBB+,E5133LTIDR2022-01-15BBB- |
Run more queries, or give the final answers.The model
**Q1.** A-. E01's LTIDR FC was set by A01 (A-, 2024-03-12) and not changed until the downgrade A02 on 2025-06-20.
**Q2.** No. E01's only 2026 actions are affirmations (A03, A04); the outlook moved to NEG but the rating stayed BBB.
**Q3.** No, it is BB+. The 2031 note I02 is subordinated and was downgraded to BB+ by A07.
**Q4.** POS. E02 and E03 share one LEI, so they are one entity; the latest action is A09 (E03, 2025-09-15), affirmed A with a Positive outlook.
**Q5.** Northwind Holdings (E02), rated A. I03 is guaranteed by E02, so it carries the guarantor's credit risk, and E02's latest rating is A (A08, A09).
**Q6.** Valdoria's Country Ceiling is BB (A12), and it caps foreign-currency ratings but not local-currency ones. E05's FC rating is BB (A14) and its LC rating is BBB- (A13).
**Q7.** 38 issuers had an LTIDR downgrade (DG) dated in 2026, including E08 and E10; the full list is in the JSON. Withdrawals, Watches and affirmations were not counted.
**Q8.** E08. Saxby Shipping was downgraded to RD by A22 on 2026-07-08 and no later action changed that.
**Q9.** 377. This counts distinct entities (records merged by LEI, QA excluded) whose latest LTIDR on 1 Oct 2026 was not a withdrawal.
**Q10.** Depends. E05's foreign-currency rating is BB (speculative grade) and its local-currency rating is BBB- (investment grade).
**Q11.** BBB+. A36 (2024-09-30) set BBB+ and the next action, A35 (2025-11-20), came later.
**Q12.** A-. A34 (2023-01-15) set it and A36 did not follow until 2024-09-30.
**Q13.** 1. The only downgrade is A36.
**Q14.** None. E12's first rating was A30 on 2024-02-01.
**Q15.** A-. E10 and E17 are one entity; the downgrade to BBB+ (A27) came on 2026-04-15.
**Q16.** No. Marlow was BBB+ on 2025-01-01 and is BBB+ now; A35 and A33 only changed the Watch status.
**Q17.** No. E06's only 2026 action is A17, a Rating Watch (RW), which is not a downgrade.
**Q18.** 32 issuers; the list is in the JSON and includes E06.
**Q19.** 47 issuers; the list is in the JSON and includes E01 and E09.
**Q20.** No. E07's rating was withdrawn for commercial reasons (A19), which is not a default; its last rating before that was BB.
**Q21.** 35 entities had an issuer rating at some point and none on 1 Oct 2026 (the latest action was a withdrawal), including E07; the list is in the JSON.
**Q22.** E08 only. It went to RD via A22.
**Q23.** F2 (A04).
**Q24.** Yes. E01's LTIDR is BBB.
**Q25.** 72. Of the 113 instruments with a rating in force on 1 Oct 2026, 72 were BBB- or higher; Expected ratings (EX) are not ratings.
**Q26.** A+ (A40, the LC rating).
**Q27.** A-. I06 was assigned A- by A42.
**Q28.** BBB+ (A38).
**Q29.** None. VD has only a Country Ceiling (A12), which is not its issuer rating.
**Q30.** 13 entities have an FC rating equal to their country's ceiling, including E15 and E05; the list is in the JSON.
**Q31.** No. No non-sovereign FC rating was above its country's ceiling.
**Q32.** E09, Halden Group plc. E11's parent is E10, whose parent is E09.
**Q33.** Halden Bank (E10), rated BBB+. I05 is guaranteed by E10, whose latest rating is BBB+ (A27).
**Q34.** No. E12 has no parent and sits outside the E09 group.
**Q35.** 3 (E09, E10, E11).
**Q36.** 2 (E02, E04).
**Q37.** 497. This is the count after merging records by LEI and excluding QA records.
**Q38.** No. They have different LEIs (E06 and E13).
**Q39.** A (A09).
**Q40.** 79, after taking country from the RESEARCH record where records disagree.
**Q41.** None. E16 is a QA record and must be ignored.
**Q42.** LU. E10 and E17 are the same entity, and RESEARCH's record (E17) holds for domicile.
**Q43.** 1 (E10/E17).
**Q44.** Yes. I07 pays in XVD, Valdoria's domestic currency.
**Q45.** No. The ceiling does not apply to local-currency debt; I07 is rated BBB- against a ceiling of BB.
**Q46.** No. E11 has only a Credit opinion (A46), which is not an issuer rating.
**Q47.** None. I08 has only an Expected rating (A47, EX), so it is still unrated.
**Q48.** 113.
**Q49.** E5001. The chain from Cerid Rosor Holdings SA to the top is 6 levels.
**Q50.** 6.
**Q51.** 58.
**Q52.** 19.
**Q53.** No. E5168 is the RESEARCH duplicate of E5062 (same LEI), and RATINGS holds for parent links, so Belir Mining sits in the Belir group, not Rotam.
**Q54.** E5106, E5124 and E5130. E5106 counts because RESEARCH (E5169) puts it in VD.
**Q55.** 31 distinct rated entities have a VD-domiciled entity above them in their chain of parents.
**Q56.** BB-. E5144 is the lowest of the group's current FC ratings.
**Q57.** E5002, 2 levels above each of them.
**Q58.** E5145. It guarantees I5007, issued by E5133 in a different group.
**Q59.** 12.
**Q60.** Geren Group SA (E5145). It is not in the issuer's group: E5133 is in the Vesol group and E5145 is in the Geren 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":["E1294","E1151","E1034","E1213","E1300","E1163","E5097","E5019","E5113","E1159","E1057","E1053","E1144","E1243","E1229","E1307","E5033","E1255","E1263","E1228","E1298","E1080","E5116","E1186","E1112","E1169","E08","E1285","E1290","E1064","E1093","E1051","E1058","E1167","E5156","E10","E5059","E1160"]},
"Q8":{"entities":["E08"]},"Q9":{"count":377},"Q10":{"investment_grade":"depends"},"Q11":{"rating":"BBB+"},"Q12":{"rating":"A-"},"Q13":{"count":1},"Q14":{"rating":"none"},"Q15":{"rating":"A-"},"Q16":{"changed":"no"},"Q17":{"downgraded":"no"},
"Q18":{"issuers":["E1013","E1297","E1238","E1061","E1317","E1242","E1037","E1209","E1181","E1133","E06","E1194","E1088","E1098","E1126","E1019","E1006","E1264","E1146","E1203","E1066","E1314","E1323","E1168","E1109","E1267","E1059","E1266","E1039","E1099","E1132","E1260"]},
"Q19":{"issuers":["E1080","E1005","E5116","E1046","E1034","E1188","E5057","E1248","E5073","E5099","E1263","E1228","E5050","E1064","E1261","E01","E1118","E5020","E1029","E5059","E1160","E5019","E5113","E1211","E5131","E09","E1158","E1105","E1079","E1055","E1294","E5119","E5141","E1271","E1190","E1072","E5156","E5039","E1300","E5102","E5097","E1059","E5062","E5013","E5023","E1056","E1282"]},
"Q20":{"in_default":"no"},
"Q21":{"entities":["E1218","E1316","E1244","E1234","E1233","E1200","E1225","E1076","E1057","E1155","E1308","E1253","E1032","E1159","E1007","E1062","E1277","E1219","E1206","E1320","E1001","E1124","E1172","E1048","E1084","E1021","E07","E1166","E1041","E1138","E1063","E1107","E1140","E1205","E1121"]},
"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":["E5047","E1194","E5124","E15","E1101","E1039","E1028","E5116","E5091","E1126","E1236","E5012","E05"]},
"Q31":{"any":"no"},"Q32":{"parent":"E09"},"Q33":{"risk_of":"E10","rating":"BBB+"},"Q34":{"same_group":"no"},"Q35":{"count":3},"Q36":{"count":2},"Q37":{"count":497},"Q38":{"same":"no"},"Q39":{"rating":"A"},"Q40":{"count":79},"Q41":{"rating":"none"},"Q42":{"country":"LU"},"Q43":{"count":1},"Q44":{"local_currency":"yes"},"Q45":{"above_ceiling":"no"},"Q46":{"issuer_rating":"no"},"Q47":{"rating":"none"},"Q48":{"count":113},"Q49":{"parent":"E5001"},"Q50":{"count":6},"Q51":{"count":58},"Q52":{"count":19},"Q53":{"same_group":"no"},"Q54":{"entities":["E5106","E5124","E5130"]},"Q55":{"count":31},"Q56":{"rating":"BB-"},"Q57":{"entity":"E5002"},"Q58":{"entities":["E5145"]},"Q59":{"count":12},"Q60":{"risk_of":"E5145","same_group":"no"},"Q61":{"count":19}}
```