Showing posts with label advanced. Show all posts
Showing posts with label advanced. Show all posts

Monday, March 26, 2012

finding average earning over period of employment

It has been a while since I have had to write a really advanced query and I was wondering if I could get a little bit of help from someone

find the average monthly earning while you have been an affiliate

affiliate_id, transaction_dt, earnings are the only fields that you have to worry about. I can obviously find the average earnings for a period of a year but, I would like something like

spavgmonthlyearning affiliate_id

any help would be greatly appreciate even a point in the right direction would be fantastic.so this will do it.
is this pure sql or will it only run on sqlserver
thank you for your help

DECLARE @.maxdate as datetime
DECLARE @.mindate as datetime
set @.maxdate = (select max(TRANS_DT) from dbo.affiliate_log)
set @.mindate = (select min(trans_dt) from dbo.affiliate_log)
select sum(earning)/datediff(M,@.mindate,@.maxdate)
from dbo.affiliate_log where affiliate_id = 1|||select DATEPART(m,date_field), avg(sales)
from table
group by DATEPART(m, date_field)|||It depends on what you mean by "average".

The simple average monthly earning would just be the total earnings divided by the total months.

select affiliate_id,
sum(earnings)/datediff(month, min(transaction_dt), max(transaction_dt))
from yourtable
group by affiliate_id

Or if they skip some months:

select affiliate_id,
sum(earnings)/count(distinct convert(varchar(7), transaction_dt, 120))
from yourtable
group by affiliate_id

Friday, March 9, 2012

Find out how much data was replicated

Hi
I use SQL Servers 2000 SP3 on Windows 2000 Advanced Server
SP4. I've set up a transactional replication w/o updating
between two servers, one of which is a publisher and the
other is a distributor/pull-subscriber. I wonder if SQL
Server has means of finding out how much data was
replicated (i.e. sent to the subscriber), say, during the
day. If it hasn't, are there any third-party tools, which
would allow me to do this?
--
Many thanks,
Oskcheck the replication monitor in EM it will display a "gross" level of
information processed by article published.
"Osk" wrote:
> Hi
> I use SQL Servers 2000 SP3 on Windows 2000 Advanced Server
> SP4. I've set up a transactional replication w/o updating
> between two servers, one of which is a publisher and the
> other is a distributor/pull-subscriber. I wonder if SQL
> Server has means of finding out how much data was
> replicated (i.e. sent to the subscriber), say, during the
> day. If it hasn't, are there any third-party tools, which
> would allow me to do this?
> --
> Many thanks,
> Osk
>|||Hi
What do you mean by "gross" level? I need to know how much
bytes were delivered to the subscriber during a time interval.
--
Thanks,
Osk
>--Original Message--
>check the replication monitor in EM it will display a
"gross" level of
>information processed by article published.
>"Osk" wrote:
>> Hi
>> I use SQL Servers 2000 SP3 on Windows 2000 Advanced Server
>> SP4. I've set up a transactional replication w/o updating
>> between two servers, one of which is a publisher and the
>> other is a distributor/pull-subscriber. I wonder if SQL
>> Server has means of finding out how much data was
>> replicated (i.e. sent to the subscriber), say, during the
>> day. If it hasn't, are there any third-party tools, which
>> would allow me to do this?
>> --
>> Many thanks,
>> Osk
>>
>.
>

Find out how much data was replicated

Hi
I use SQL Servers 2000 SP3 on Windows 2000 Advanced Server
SP4. I've set up a transactional replication w/o updating
between two servers, one of which is a publisher and the
other is a distributor/pull-subscriber. I wonder if SQL
Server has means of finding out how much data was
replicated (i.e. sent to the subscriber), say, during the
day. If it hasn't, are there any third-party tools, which
would allow me to do this?
Many thanks,
Oskcheck the replication monitor in EM it will display a "gross" level of
information processed by article published.
"Osk" wrote:

> Hi
> I use SQL Servers 2000 SP3 on Windows 2000 Advanced Server
> SP4. I've set up a transactional replication w/o updating
> between two servers, one of which is a publisher and the
> other is a distributor/pull-subscriber. I wonder if SQL
> Server has means of finding out how much data was
> replicated (i.e. sent to the subscriber), say, during the
> day. If it hasn't, are there any third-party tools, which
> would allow me to do this?
> --
> Many thanks,
> Osk
>|||Hi
What do you mean by "gross" level? I need to know how much
bytes were delivered to the subscriber during a time interval.
Thanks,
Osk

>--Original Message--
>check the replication monitor in EM it will display a
"gross" level of
>information processed by article published.
>"Osk" wrote:
>
>.
>

Find out how much data was replicated

Hi
I use SQL Servers 2000 SP3 on Windows 2000 Advanced Server
SP4. I've set up a transactional replication w/o updating
between two servers, one of which is a publisher and the
other is a distributor/pull-subscriber. I wonder if SQL
Server has means of finding out how much data was
replicated (i.e. sent to the subscriber), say, during the
day. If it hasn't, are there any third-party tools, which
would allow me to do this?
Many thanks,
Osk
check the replication monitor in EM it will display a "gross" level of
information processed by article published.
"Osk" wrote:

> Hi
> I use SQL Servers 2000 SP3 on Windows 2000 Advanced Server
> SP4. I've set up a transactional replication w/o updating
> between two servers, one of which is a publisher and the
> other is a distributor/pull-subscriber. I wonder if SQL
> Server has means of finding out how much data was
> replicated (i.e. sent to the subscriber), say, during the
> day. If it hasn't, are there any third-party tools, which
> would allow me to do this?
> --
> Many thanks,
> Osk
>
|||Hi
What do you mean by "gross" level? I need to know how much
bytes were delivered to the subscriber during a time interval.
Thanks,
Osk

>--Original Message--
>check the replication monitor in EM it will display a
"gross" level of
>information processed by article published.
>"Osk" wrote:
>.
>