Solved

Help with tables

Posted on 2011-03-23
4
209 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
[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
  • Learn & ask questions
  • 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
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 show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

635 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