D1 sql, run 5: the query session
3 queries0 failed1 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` (19 rows): entity_id, name, lei, country, entity_type, parent_id, source_system
- `instruments` (8 rows): instrument_id, description, issuer_id, guarantor_id, seniority, currency, maturity
- `rating_actions` (47 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)
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?The model
Let me look at the data.
```sql
SELECT * FROM entities ORDER BY entity_id;
```
```sql
SELECT * FROM instruments ORDER BY instrument_id;
```
```sql
SELECT * FROM rating_actions ORDER BY rated_id, date, action_id;
```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 |
| 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 |
| VD | Republic of Valdoria | | VD | SOV | | RATINGS |
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 |
Query 3:
| 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 | | |
| 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 | | | |
| 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 | | |
| A40 | 2024-03-01 | E15 | LTIDR | LC | AS | A+ | STA | | |
| A41 | 2024-03-01 | E15 | LTIDR | FC | 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 | | | |
| A12 | 2025-04-01 | VD | CC | | AS | BB | | | |
Run more queries, or give the final answers.The model
**Q1.** A-. Kestrel's rating was A- from A01 (2024-03-12) until the downgrade to BBB in A02 on 2025-06-20.
**Q2.** No. In 2026, A03 affirmed BBB and moved the outlook to Negative, with no rating cut.
**Q3.** No. The 2031 note (I02) is rated BB+ after A07, which is below investment grade.
**Q4.** Positive. E02 and E03 share an LEI, so I treated them as one entity. Its latest action, A09 (2025-09-15), has a POS outlook.
**Q5.** The holder takes the credit risk of E02, the guarantor of I03, and the note is rated A (A10, A11).
**Q6.** The Valdoria country ceiling (A12) is BB. That caps Valdoria Telecom's foreign-currency rating at BB (A14), while its local-currency rating is BBB- (A13).
**Q7.** E08, E10 and E16. They were downgraded in A21 and A22, A27, and A44 respectively. I05's downgrade (A29) is an instrument action only, driven by guarantor E10.
**Q8.** E08. A22 on 2026-07-08 set it to RD, and nothing later changes that.
**Q9.** 13. These are CV, E01, E02 (with E03), E05, E06, E08, E09, E10, E12, E13, E14, E15 and E16. E07 is withdrawn, E11 has only a "CO" record, and VD has only a country ceiling.
**Q10.** Depends. The foreign-currency rating is BB (not investment grade) and the local-currency rating is BBB- (investment grade).
**Q11.** BBB+. A36 downgraded E14 from A- on 2024-09-30.
**Q12.** A-, from A34.
**Q13.** 1. Marlow has one downgrade, A36. A35 and A33 are watch and affirmation actions.
**Q14.** None. E12's first rating, A30, is dated 2024-02-01.
**Q15.** A-. E10 held A- from A26 until the downgrade on 2026-04-15, and E17 is a duplicate of E10.
**Q16.** No. It was BBB+ on 2025-01-01 and is BBB+ now (A33). Only the watch and outlook changed.
**Q17.** No. A17 (2026-09-03) only placed it on Rating Watch Negative at A-.
**Q18.** E06, from A17. E14's watch (A35) was resolved by A33.
**Q19.** E01 and E09, from A03 and A25.
**Q20.** No. A19 withdrew the rating for commercial reasons, and the last rating before that was BB.
**Q21.** E07, because of the withdrawal in A19.
**Q22.** E08, from the RD rating in A22.
**Q23.** F2, from A04.
**Q24.** Yes. The issuer rating is BBB (A03).
**Q25.** 5. These are I01 (BBB), I03 (A), I05 (BBB+), I06 (A-) and I07 (BBB-). I02 and I04 are below investment grade, and I08 is excluded, as explained under Q47.
**Q26.** A+, from A40.
**Q27.** A-, from A42.
**Q28.** BBB+, from A38.
**Q29.** None. VD has only a Country Ceiling (A12), not an issuer rating.
**Q30.** E05 and E15. E05's foreign-currency rating of BB equals the Valdoria ceiling of BB, and E15's A equals the Corvenia ceiling of A.
**Q31.** No. None is above its ceiling.
**Q32.** E09, via E11 โ E10 โ E09.
**Q33.** The holder takes the risk of E10, the guarantor, and the note is rated BBB+ (A29).
**Q34.** No. E12 has no parent link to E09 or E10, and the shared "Halden" name is not evidence of a group.
**Q35.** 3: E09, E10 and E11. E17 duplicates E10 (same LEI).
**Q36.** 2: E02 and E04. E03 duplicates E02.
**Q37.** 17. The 19 rows contain two duplicates, E03 (of E02) and E17 (of E10), identified by shared LEIs.
**Q38.** No. They have different LEIs (E06 and E13), different countries and different entity records.
**Q39.** A. E02 was assigned A in A08 and affirmed at A via E03 in A09.
**Q40.** 6: E01, E02, E09, E12, E14 and E16.
**Q41.** BB+, from A44. The entity's source system is "QA", so this may be test data.
**Q42.** DE. The LU value comes only from the duplicate research row E17.
**Q43.** 0. The only LU record is E17, which duplicates the German E10.
**Q44.** Yes. I07 is denominated in XVD, Valdoria's currency.
**Q45.** No. The ceiling caps foreign-currency ratings, and I07 is local-currency (BBB-).
**Q46.** No. E11 has only a "CO" record (A46), not an issuer rating (LTIDR).
**Q47.** None. The only action on I08 is A47 with code "EX", which the data does not define. I read it as an expected or provisional rating (A), not a held rating, so this answer rests on that reading.
**Q48.** 7: I01 to I07. This also excludes I08 for the reason given under Q47.
```json
{
"Q1": {"rating": "A-"},
"Q2": {"downgraded": "no"},
"Q3": {"investment_grade": "no", "rating": "BB+"},
"Q4": {"outlook": "Positive"},
"Q5": {"risk_of": "E02", "rating": "A"},
"Q7": {"issuers": ["E08", "E10", "E16"]},
"Q8": {"entities": ["E08"]},
"Q9": {"count": 13},
"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": ["E06"]},
"Q19": {"issuers": ["E01", "E09"]},
"Q20": {"in_default": "no"},
"Q21": {"entities": ["E07"]},
"Q22": {"entities": ["E08"]},
"Q23": {"rating": "F2"},
"Q24": {"investment_grade": "yes"},
"Q25": {"count": 5},
"Q26": {"rating": "A+"},
"Q27": {"rating": "A-"},
"Q28": {"rating": "BBB+"},
"Q29": {"rating": "none"},
"Q30": {"entities": ["E05", "E15"]},
"Q31": {"any": "no"},
"Q32": {"parent": "E09"},
"Q33": {"risk_of": "E10", "rating": "BBB+"},
"Q34": {"same_group": "no"},
"Q35": {"count": 3},
"Q36": {"count": 2},
"Q37": {"count": 17},
"Q38": {"same": "no"},
"Q39": {"rating": "A"},
"Q40": {"count": 6},
"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": 7}
}
```