Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Fredforfree
Starting Member
49 Posts |
Posted - 2014-08-14 : 09:49:58
|
Hi,I am trying to figure out what this query is doing, I do not see FSUM or Live column fields in the table. Select B.Rpt_date,B.Emp_No,Cast (0 as Int) Deacts,Cast (0 as float) ARPU,Cast (0 as Int) FSUM,Cast (0 as Int) Live,Cast (0 as Int) Calls,Cast (0 as Int) Norm_Deacts,Cast (Sum(Isnull(A.No_of_Fsums,0)) as Int) BMBI_FSUMS Into ##FSUMRAWfrom openquery(TERADATA_BMBI, '' Select sys_creation_date,cfr_Operator_id,no_of_fsums From MI_REPORT.V_ODS_BM_FSUM_T_DAILY_FSUM_V2 Where SYS_CREATION_DATE BETWEEN ''''' + @From + ''''' and ''''' +@to + ''''' and CFR_OPERATOR_ID IS NOT NULL '') as Ainner join ##Tracker as Bon cast(floor(Cast(A.sys_creation_date as float)) as datetime) = B.rpt_date and A.cfr_Operator_id =B.idensembleGroup by B.Rpt_Date,B.Emp_no'SelectRpt_Date,Emp_No,Sum (FSUM+LIVE) as Deacts,Sum (True_ARPU) as ARPU,Sum (FSUM) as FSUM,Sum (Live) as Live,Sum (Calls) as Calls,Sum (Norm_Fsums+Norm_Lives) as Norm_Deacts,Cast (0 as Int) as BMBI_FSUMS From DEACT.dbo.T_FCT_AGENT_DAILY_DEACTWhere rpt_date >= @St_Date and rpt_date < @End_Date + 1Group By Rpt_date, Emp_NoFred |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-08-14 : 09:58:43
|
works for me:Select 'B.Rpt_date' Rpt_Date,'B.Emp_No' Emp_No,Cast (0 as Int) Deacts,Cast (0 as float) ARPU,Cast (0 as Int) FSUM,Cast (0 as Int) Live,Cast (0 as Int) Calls,Cast (0 as Int) Norm_Deacts--,Cast (Sum(Isnull(A.No_of_Fsums,0)) as Int) BMBI_FSUMSInto ##FSUMRAWselect * from ##FSUMRAW yields:Rpt_Date Emp_No Deacts ARPU FSUM Live Calls Norm_DeactsB.Rpt_date B.Emp_No 0 0 0 0 0 0 |
 |
|
Fredforfree
Starting Member
49 Posts |
Posted - 2014-08-14 : 10:02:05
|
Sorry I think I was not clear in my question.The field name Live and FSum do not appear in raw data table.If I do select * from MI_REPORT.V_ODS_BM_FSUM_T_DAILY_FSUM_V2 Fred |
 |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-08-14 : 10:19:41
|
OK -- then it's not defined. Please post the CREATE TABLE command for this table. |
 |
|
Fredforfree
Starting Member
49 Posts |
Posted - 2014-08-14 : 11:22:56
|
I do not have access to such info sorry.Fred |
 |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2014-08-14 : 11:31:11
|
Your first statement which creates and inserts data into the ##FSUMRAW table retrieves some columns from the source table MI_REPORT.V_ODS_BM_FSUM_T_DAILY_FSUM_V2, and adds some additional columns (Including FSUM) even though they are not in the raw table. For the columns it adds, it is setting the value as 0.So even though MI_REPORT.V_ODS_BM_FSUM_T_DAILY_FSUM_V2 does not have the column FSUM, ##FSUMRAW does. |
 |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-08-14 : 11:52:22
|
quote: Originally posted by Fredforfree I do not have access to such info sorry.Fred
OK, then highlight the table name in SSMS and hit Alt-F1. Then post the results |
 |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2014-08-14 : 19:15:03
|
The SELECT is using constants for most of the columns; FSUM (and others) are just column aliases for the constants. They are there so that the temp table created has names to apply to its columns. Too often we enjoy the comfort of opinion without the discomfort of thought. - John F. Kennedy |
 |
|
|
|
|
|
|