script query
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.


script query Expand / Collapse
Author
Message
Posted 3/23/2006 5:31:04 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 3/23/2006 5:10:00 AM
Posts: 1, Visits: 1
Hi guys

I have a slightly generic query. I have a table with actual sales and budget per week for the whole year, and another table which holds calender information, which I link my first table to work out which figures belong to which company weeks. What I want to do is an equation along the lines of:

[Actual.Lastweek]-[Budget.Thisweek]

My problem is that both actuals and budgets are in the same table so how can I work out the actual sales last week and take it away from this week's budget in one sql string? I've got the following code just to work out sales from last week.

SELECT sum(ACTUAL_SALES_VALUE)
FROM MEASURES_DATA ON B.Retail_Outlet_Number
= A.RETAIL_OUTLET_NUMBER Inner Join VWI0CAL_SMALL_CALENDAR C ON
A.ssw_TIME = C.year_week_number
GROUP_BY Calendar_Date,
A.SSW_TIME, A.MEASURE_ID, B.Trading_Status_Ind
HAVING ((AND ((A.MEASURE_ID)='ATSV'))
AND (Calendar_Date = (date-7))


the "MEASURES_DATA" table holds sales by day, hence I use the calender table to work out week sales, if that makes sense. Now I just need to do something similar to work out this week's budget, and take one away from the other, but not sure how to go about it.

Any help would be appreciated

Many thanks

Oz


this isn't a parachute, it's a nappy sack!
Post #3816
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 2 ( 2 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 11:57pm

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.203. 9 queries. Compression Disabled.