Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

Table defination

$
0
0

CREATE VIEW [dbo].[vw_fact_unprocessed_sales] AS
SELECT 
      a.[product_key]
     ,a.[division_key]
      ,f.[division_code]
      ,[warehouse_key]
      ,a.[period_key]
      ,[snapshot_key] as calendar_key      
      ,h.fiscal_year
      ,h.fiscal_period
      ,tender_no
     ,0 as tender_year
      ,[delivered_qty] as invoice_quantity      
      ,std_cost_price * [delivered_qty] as cos_value
      ,[gross_value]
      ,0 as [bonus_cos_value]
      ,NULL as [calendar_period]
 ,[currency]       
 ,g.[Main Division] AS main_division_group_name
 ,a.[delivered_qty] * i.sep_price as SEP    
  FROM [edw].[dbo].[fact_unprocessed_sales] a
LEFT OUTER JOIN JNBVDW02A.edw.dbo.dim_product b ON a.product_key = b.product_key
LEFT OUTER JOIN JNBVDW02A.edw.dbo.dim_division f ON a.division_key = f.division_key
LEFT OUTER JOIN JNBVDW02A.edw.dbo.dim_daily_sales_groupings g ON a.division_key=g.division_key
INNER JOIN JNBVDW02A.edw.dbo.vw_dim_period h on a.period_key = h.period_key
LEFT OUTER JOIN JNBVDW02A.edw.dbo.vw_fact_single_exit_price i ONa.product_key = i.product_key and a.period_key = i.period_key 

How can I get the calendar_period as varchar(12) .
When I am creating this view , calendar_period is INT.


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>