title: Teradata Result set view
body: <p>When trying to run this query/command:</p>
  <pre><code>CREATE MULTISET VOLATILE TABLE SRB AS
      (
      SELECT 
      -- As the grain of this table is Account x Cuustomer, all Account amounts are divided by number of customers / multiplied b Account_Portion_Percent
      REL.LOAD_DATE AS BUSINESS_DATE
      , ACC_FACS.ACCOUNT_GENERAL_IDENTIFIER
      , CUST.CUSTOMER_IDENTIFIER
      , CUST.CUSTOMER_NAME
      , ACC_DIMS.LIQUIDITY_ACCOUNT_STATUS_INDICATOR
      , ACC_DIMS.INTERCOMPANY_INDICATOR
      , ACC_DIMS.INTERBANK_INDICATOR
      --.intercompany_code_unit_identifier
      , ACC_DIMS.CONTROL_ACCOUNT_INDICATOR
      , ACC_DIMS.ACCOUNT_CLOSED_INDICATOR
      , ACC_DIMS.UNIQUE_ACCOUNT_NUMBER
      , ACC_DIMS.CUSTOMER_LIQUIDITY_DEPOSIT_INDICATOR
      , ACC_DIMS.NIAC_ACCOUNT_INDICATOR
      , CUST.REGULATORY_AUTHORITY_IDENTIFIER
      , ACC_DIMS.COMPANY_CODE_UNIT_IDENTIFIER 
      , ACC_DIMS.SOURCE_SYSTEM_IDENTIFIER   --- 
      , ACC_FACS.LEDGER_BALANCE_SIGNAGE
      , ACC_FACS.TOTAL_ACCOUNT_BALANCE_SIGNAGE AS TOTAL_ACCOUNT_BALANCE_SIGNAGE
      , CASE WHEN ACC_DIMS.CUSTOMER_LIQUIDITY_DEPOSIT_INDICATOR = 'Yes' AND ACC_FACS.TOTAL_ACCOUNT_BALANCE_SIGNAGE = 'Credits' THEN 'Yes' ELSE 'No' END AS CUSTOMER_DEPOSITS_FILTER
      , CASE WHEN CUSTOMER_DEPOSITS_FILTER = 'Yes' OR (ACC_DIMS.NIAC_ACCOUNT_INDICATOR = 'Yes' AND ACC_FACS.TOTAL_ACCOUNT_BALANCE_SIGNAGE = 'Credits' )THEN 'Yes' ELSE 'No' END AS NIAC_CUSTOMER_DEPOSITS_FILTER
  
      , REL.ACCOUNT_PORTION_PERCENT
      , 0 AS NO_OF_DEPOSITS_HELD_COUNT  -- Placeholder 2017-10-10 to enable No. Of Cust to be calc'd i  SELECT below.
      , ACC_DIMS.Account_Guarantee_Eligible_Indicator 
      , CUST.Customer_Guarantee_Eligible_Indicator 
      , REL. Guarantee_Eligible_Indicator 
      , ACC_DIMS.PRODUCT_IDENTIFIER
      , CUST.BASEL_III_CUSTOMER_TYPE_IDENTIFIER
      , acc_dims.Account_Basel_III_Customer_Type_Identifier
      , CUST.COUNTRY_OF_RESIDENCE_COUNTRY_IDENTIFIER
      , ACC_DIMS.COUNTRY_OF_PRODUCT_IDENTIFIER  
      , ACC_DIMS.INTERCOMPANY_COMPANY_CODE_UNIT_IDENTIFIER
      , ACC_DIMS.ACCOUNT_CURRENCY_IDENTIFIER
      , ACC_DIMS.ACCOUNT_OPEN_DATE
      , ACC_FACS.REMAINING_IN_COOL_OFF_DAY_COUNT
      , ACC_DIMS.CONTRACT_START_DATE
      , ACC_FACS.CONTRACTUAL_MATURITY_DATE
      -- Count each account for a depositor as a &quot;fraction&quot; of that depositor. So if I have 4 accounts, return 0.25 so when I add them all back togther the result will be 1 customer
      ,  1.000000 /  ( COUNT (CASE WHEN LIQUIDITY_ACCOUNT_STATUS_INDICATOR = 'Y' AND CUSTOMER_DEPOSITS_FILTER = 'Yes ' THEN 1 ELSE 0 END ) OVER (PARTITION BY CUST.CUSTOMER_IDENTIFIER)  )   AS NO_OF_CUSTOMERS_COUNT
      , CAST ( COALESCE (ACC_FACS.LEDGER_BALANCE_AMOUNT,0) * ACCOUNT_PORTION_PERCENT /100 AS DECIMAL (21,5)) AS LEDGER_BALANCE_AMOUNT
      , CAST (COALESCE (ACC_FACS.CREDIT_INTEREST_ACCRUAL_AMOUNT,0) * ACCOUNT_PORTION_PERCENT /100 AS DECIMAL (21,5)) AS CREDIT_INTEREST_ACCRUED_AMOUNT
      , CAST ( COALESCE (ACC_FACS.DEBIT_INTEREST_ACCRUAL_AMOUNT,0) * ACCOUNT_PORTION_PERCENT /100 AS DECIMAL (21,5)) AS DEBIT_INTEREST_ACCRUED_AMOUNT
      , CAST (COALESCE (ACC_FACS.INTEREST_ACCRUED_AMOUNT,0) * ACCOUNT_PORTION_PERCENT /100 AS DECIMAL (21,5)) AS INTEREST_ACCRUED_AMOUNT
      , COALESCE (ACC_FACS.ACCOUNT_HOLDER_PORTION_BALANCE_AMOUNT,0) AS  ACCOUNT_HOLDER_PORTION_BALANCE_AMOUNT
      , CAST (COALESCE ( ACC_FACS.COOL_OFF_AMOUNT,0) * ACCOUNT_PORTION_PERCENT /100 AS DECIMAL (21,5)) AS COOL_OFF_AMOUNT
  
  
      , COALESCE (REL.BASE_CASH_FLOW_LEDGER_BALANCE_GUARANTEED_AMOUNT ,0) AS BASE_CASH_FLOW_LEDGER_BALANCE_GUARANTEED_AMOUNT
      , COALESCE (REL.BASE_CASH_FLOW_LEDGER_BALANCE_UNGUARANTEED_AMOUNT ,0) AS BASE_CASH_FLOW_LEDGER_BALANCE_UNGUARANTEED_AMOUNT
      , COALESCE (REL.BASE_CASH_FLOW_LEDGER_BALANCE_AMOUNT ,0) AS BASE_CASH_FLOW_LEDGER_BALANCE_AMOUNT
  
      , COALESCE (REL.BASE_CASH_FLOW_INTEREST_ACCRUED_GUARANTEED_AMOUNT ,0) AS BASE_CASH_FLOW_INTEREST_ACCRUED_GUARANTEED_AMOUNT
      , COALESCE (REL.BASE_CASH_FLOW_INTEREST_ACCRUED_UNGUARANTEED_AMOUNT ,0) AS BASE_CASH_FLOW_INTEREST_ACCRUED_UNGUARANTEED_AMOUNT
      , COALESCE (REL.BASE_CASH_FLOW_INTEREST_ACCRUED_AMOUNT ,0) AS BASE_CASH_FLOW_INTEREST_ACCRUED_AMOUNT
  
      , COALESCE (REL.BASE_CASH_FLOW_GUARANTEED_AMOUNT ,0) AS BASE_CASH_FLOW_GUARANTEED_AMOUNT
      , COALESCE (REL.BASE_CASH_FLOW_UNGUARANTEED_AMOUNT ,0) AS BASE_CASH_FLOW_UNGUARANTEED_AMOUNT
      , COALESCE (REL.BASE_CASH_FLOW_AMOUNT ,0) AS BASE_CASH_FLOW_AMOUNT
  
      , CAST (COALESCE (ACC_FACS.ACCOUNT_ACCESSIBILITY_CREDIT_AMOUNT,0) * ACCOUNT_PORTION_PERCENT /100 AS DECIMAL (21,5)) AS ACCOUNT_ACCESSIBILITY_CREDIT_AMOUNT
      , COALESCE (REL.DEPOSIT_GUARANTEED_ACCOUNT_HOLDER_PORTION_AMOUNT,0) AS GUARANTEED_AMOUNT
      -- Unguaranteed amount is Total Balance minus Guaranteed portion
      , GREATEST (0, COALESCE (ACC_FACS.ACCOUNT_HOLDER_PORTION_BALANCE_AMOUNT,0) - COALESCE (REL.DEPOSIT_GUARANTEED_ACCOUNT_HOLDER_PORTION_AMOUNT,0) ) AS UNGUARANTEED_AMOUNT
  
  
  
      FROM 
      REL
  
      LEFT OUTER JOIN
      CUST
      ON REL.HARMO_CUST_ID = CUST.CUSTOMER_IDENTIFIER
  
      LEFT OUTER JOIN
      ACC_FACS
      ON REL.AGMT_ID = ACC_FACS.ACCOUNT_GENERAL_IDENTIFIER
  
      LEFT OUTER JOIN
      ACC_DIMS
      ON REL.AGMT_ID = ACC_DIMS.ACCOUNT_GENERAL_IDENTIFIER
      
      where
      ACC_DIMS.Source_System_IDENTIFIER = 30
      
      )
  WITH DATA
  PRIMARY INDEX (ACCOUNT_GENERAL_IDENTIFIER, CUSTOMER_IDENTIFIER)
  INDEX (CUSTOMER_IDENTIFIER)
  INDEX (ACCOUNT_GENERAL_IDENTIFIER)
  INDEX (UNIQUE_ACCOUNT_NUMBER)
  ON COMMIT PRESERVE ROWS
  ;
  </code></pre>
  <p>I get the following error:</p>
  <p><a href="https://i.stack.imgur.com/v0kYB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v0kYB.png" alt="enter image description here" /></a></p>
  <p>I dont know what is the root cause of this error, as it only happens when i get to this stage. all other tables match up correctly...i dont know if this is caused by a typo or something in the script or something to do with my teradata studio.</p>
  <p>If anyone could help, or has come across a similar issue.</p>
  <p>Best,</p>