Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

CREATE TABLE local_core.circ_snapshot4
 AS 
 SELECT 
  now() AS extract_date,
  li.loan_id,
  li.item_id,
  li.barcode,
  li.loan_date,
  li.loan_return_date,
  li.patron_group_name,
  uu.custom_fields__department,
  uu.custom_fields__college,
  udu.department_code
 
 FROM folio_reporting.loans_items AS li 
  LEFT JOIN user_users AS uu 
  ON li.user_id = uu.idid  
  
  LEFT JOIN folio_reporting.users_departments_unpacked AS udu 
  ON li.user_id = udu.user_id 
  
 WHERE li.user_id IS NOT NULL
;
 

...


INSERT INTO local_core.circ_snapshot4
SELECT 
  now() AS extract_date,
  li.loan_id,
  li.item_id,
  li.barcode,
  li.loan_date,
  li.loan_return_date,
  li.patron_group_name,
  uu.custom_fields__department,
  uu.custom_fields__college,
  udu.department_code
 
 FROM folio_reporting.loans_items AS li 
  LEFT JOIN user_users AS uu 
  ON li.user_id = uu.idid  
  
  LEFT JOIN folio_reporting.users_departments_unpacked AS udu 
  ON li.user_id = udu.user_id
  
 WHERE 
 li.loan_id NOT IN  
  (SELECT cs4.loan_id 
  FROM local_core.circ_snapshot4 AS cs4
  )
 AND li.user_id IS NOT NULL
 ;

...

Here is a screenshot of the local_core.circsnapshot4 sm_circs_snapshot4 table in the LDPMetadb


Image RemovedImage Added