/*****************************************************************************
*
* Filename         - $Workfile:   security_bag_month_v1.sql  $
*
*                     Name              Date      Version     CR Number
*                     MGC Helliwell   01/08/01      1.2       15477
*                     MGC Helliwell   28/08/01      1.3       15496
* Author           - See revision history below.
* Last Update      - See revision history below.
*
* Project Name     - TAGTRAK(Oracle Database)
*
* Source Code
* Identifier       - 0/3/300/8010/112
*
* Design Spec
* Section          - 
*
* Contents         - Live Schema View
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 2000
*
*****************************************************************************/
/****************************************************************************
* @(#)$Workfile:   security_bag_month_v1.sql  $  $Revision:   1.3  $
*
* Revision History
*
* Note that user tagtrak is many users. For these users the user
* name is entered as the last line in the change description.
*
* $Log:   /pvcsarch/db_ora/db/source/live/views/security_bag_month_v1.svl  $
* 
*    Rev 1.3   29 Aug 2001 11:11:54   tagtrak
* OR:
* CR: 15496
* REV: 1.3
* DESC: Reduce size of carrier_desc by 1
* 
*    Rev 1.2   07 Aug 2001 18:35:58   tagtrak
* OR:
* CR: 15477
* REV: 1.2
* DESC: RFID patch for SFO
* 
*    Rev 1.1   21 Jun 2001 15:37:50   tagtrak
* OR:
* CR:
* Re-baseline version 4.0.0 to include patches.
* 
*    Rev 1.0   25 Sep 2000 11:46:10   tagtrak
* OR:
* CR: 15247
* REV:
*
*****************************************************************************/
PROMPT CREATE OR REPLACE FORCE view security_bag_month_v1

CREATE OR REPLACE FORCE
view security_bag_month_v1 AS
SELECT
TRUNC(ltr.month_end(flight_date)) 			END_DATE
,flight_date
,flight_no
,SUM(check_in)													CHECK_IN
,SUM(level_one)													LEVEL_ONE
,ROUND((NVL(SUM(level_one),0) / DECODE(SUM(check_in),NULL,1,0,1,SUM(check_in))) * 100) READ_RATE
,SUM(level_three)												LEVEL_THREE
,SUM(level_four)												LEVEL_FOUR
,SUBSTR(carrier_desc,1,22)      				CARRIER_DESC
,contracted_agents.agent_code
FROM rfid_totals
,contracted_agents
WHERE SUBSTR(flight_no,1,3) = airline_alpha_code
AND SUBSTR(flight_no,4,4) BETWEEN min_flight_no AND max_flight_no
GROUP BY
TRUNC(ltr.month_end(flight_date)) 			
,flight_date
,flight_no
,SUBSTR(carrier_desc,1,22)
,contracted_agents.agent_code
/
