Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Help with tables

Posted on 2011-03-23
Medium Priority
214 Views
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

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?

Hope am not confusing you.
0
Question by:parpaa
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 3

Author Comment

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

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 40

Expert Comment

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

ID: 35292482
this task is not required anymore.

Cheers
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
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…
###### Suggested Courses
Course of the Month6 days, 3 hours left to enroll