Solved

Help with tables

Posted on 2011-03-23
4
205 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 40

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

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
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
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

821 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