Solved

Help with tables

Posted on 2011-03-23
4
202 Views
Last Modified: 2012-05-11
I have table Collection_Dashboard (accno, del_no,value_Segment, circle, region,NAD_count, BC, Cust_name, last_invoice_date, acc_bal)


Consider  that the above table is my base table, now I will add few calculated columns
Say I have another table Cluster (Cluster,Region)
Now I have new column Cluster from the Cluster table based on Region column.
I did the left outer join and got the cluster column.
Second calculated column:
DELIQUENCY_DAY = DATEDIFF(DD,[LAST_INVOICE_DATE],GETDATE)

Third Calculated Column:
FROM THE NEW DERIVED COLUMN DELIQUENCY_DAY NEW COLUMN IS CALCULATED WHICH IS “OVER DUE” BASED ON CONDITION:-
IF THE DELIQUENCY_DAY COLUMN IS GREATER THAN 21 THEN ‘YES’ ELSE ‘NO’
So at this point I have 3 calculated columns created.
Eventually I would like to have result set as all columns from base table and few calculated columns

What I had done now is I had derived cluster column and delinquency _day from base table and inserted into new table TM_deli. So now my table TM_DELI have fields
(accno, del_no,value_Segment, circle, region,NAD_count, BC, Cust_name, last_invoice_date, acc_bal, cluster,delinquency_day) now at this point I have 2 columns created

To add third column,
With simple case statement I can calculate the OVER DUE column. I stuck up here, do I have to create new table and add this column to it?
Please help me out.



Hope am not confusing you.
0
Comment
Question by:parpaa
  • 3
4 Comments
 

Author Comment

by:parpaa
ID: 35200973
Please find the attachment of my table structures.
I know, this is very wrong way of creating tables, please suggest.
to make things worst, no keys on these tables.
dashboard-table.xlsx
0
 

Accepted Solution

by:
parpaa earned 0 total points
ID: 35201011
Is there any alternative way of calculating these columns and stored in some temp (or something I dont know),  avoiding in creation of multiple tables.
0
 
LVL 39

Expert Comment

by:lcohan
ID: 35202173
You should be able to get the third column with a simple CASE like below:

CASE WHEN DELIQUENCY_DAY > 21 THEN 'YES' ELSE 'NO' END AS column_name

FROM ....
0
 

Author Closing Comment

by:parpaa
ID: 35292482
this task is not required anymore.

Cheers
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now