romeiovasu
asked on
sql 2005 trend query.
i have a data.
sales
25,000
60,000
12,000
i want to write a query to show the trend for those sales. or a function so that it automatically can trend. so that i can use that function for everything.
i want like (sales*noofdaysinamonth)/p resentday
so that i can show the trend for sales.
sales
25,000
60,000
12,000
i want to write a query to show the trend for those sales. or a function so that it automatically can trend. so that i can use that function for everything.
i want like (sales*noofdaysinamonth)/p
so that i can show the trend for sales.
can you give an example of what you'd want the output to look like?
ASKER
sales Trend
$25,000.00 $37,500.00
$60,000.00 $90,000.00
$12,000.00 $18,000.00
here is the sample.
it actually done like this. trend = (sales*noofdaysinamonth)/d ayofthemon th.
$25,000.00 $37,500.00
$60,000.00 $90,000.00
$12,000.00 $18,000.00
here is the sample.
it actually done like this. trend = (sales*noofdaysinamonth)/d
Great...this should do it:
select (Sales * day(dateadd(d, -1, cast(cast(month(dateadd(m, 1, getdate())) as varchar(2)) + '/1/' + cast(year(getdate()) as varchar(4)) as datetime)))) / day(getdate())
FRom YOurTableName
select (Sales * day(dateadd(d, -1, cast(cast(month(dateadd(m,
FRom YOurTableName
ASKER
if i want to create the samething as a funtion how can i do that.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you
ASKER
thank you
very welcome.