I have what I thought was going to be a fairly simple task of writing a report to calculate Miles Per Gallon in a vehicle fleet. The data format goes like this:
Trans_Date Gals Odometer
09/13/2006 16.3 4827
09/25/2006 14.6 5035
09/29/2006 12.3 5220
I need to calculate the MPG for a given time period. I have written a formula to calculate MPG for each fuel transaction but when I try to sum or average those results I get the dreaded "Cannot summerize field" message. I have also tried calculating on the given data but in the example given I cannot figure out how to exclude the 16.3 entry from the calculation since those gallons are not a factor for this time period.I have what I thought was going to be a fairly simple task of writing a report to calculate Miles Per Gallon in a vehicle fleet. The data format goes like this:
Trans_Date Gals Odometer
09/13/2006 16.3 4827
09/25/2006 14.6 5035
09/29/2006 12.3 5220
I need to calculate the MPG for a given time period. I have written a formula to calculate MPG for each fuel transaction but when I try to sum or average those results I get the dreaded "Cannot summerize field" message. I have also tried calculating on the given data but in the example given I cannot figure out how to exclude the 16.3 entry from the calculation since those gallons are not a factor for this time period.
Format the Gals field. At the suppress formula: isnull (previous({galsfield}))
new formula, @.MPG: ({milesfield}-previous({milesfield}))/{galsfield)
new summary, grand total average @.MPG|||Jeffro308,
Thanks for responding to my post!
I am trying your approach but CR 9 does not like the isnull statement as written. I am getting the "A field is required here" message as long as I include the 'previous' function. Any further ideas?|||I'm using 8.5 so there might be a difference. I need to try a couple things at work monday.
Jeffro308,
Thanks for responding to my post!
I am trying your approach but CR 9 does not like the isnull statement as written. I am getting the "A field is required here" message as long as I include the 'previous' function. Any further ideas?|||bump|||Anybody else want to take a stab at this?|||I'll assume you're grouping by vehicle and ordering by odo, and that your 3 rows of sample data are for one vehicle.
I guess you want, per vehicle, the number of gals to be the sum of all records except the first, and the number of miles to be the last record minus the first.
So you could put a formula in the group header to subtract the gals and store the first odo, a formula in the details to add the gals, and a formula in the footer to subtract the stored first odo from the current odo.
e.g.
group header:
whileprintingrecords;
numbervar total_gals:= total_gals - {table.gals};
numbervar vehicle_gals := -{table.gals}; --or maybe {table.gals} * -1
numbervar first_vehicle_odo := {table.odo};
details:
whileprintingrecords;
numbervar total_gals := total_gals + {table.gals};
numbervar vehicle_gals := vehicle_gals + {table.gals};
group footer:
whileprintingrecords;
numbervar first_vehicle_odo;
numbervar vehicle_miles := {table.odo} - first_vehicle_odo;
numbervar total_miles := total_miles + vehicle_miles;
--and display miles/gallon for the vehicle
vehicle_miles / vehicle_gals --You should add a divide by zero check here for when there's only one record
report footer:
whileprintingrecords;
numbervar total_gals;
numbervar total_miles;
--and display miles/gallon for the report
total_miles / total_gals --divide by zero check again
By the way, I've not tried this explicitely but it might give you a start / ideas.sql
Showing posts with label task. Show all posts
Showing posts with label task. Show all posts
Friday, March 30, 2012
Wednesday, March 21, 2012
Moving SQL Server to a new domain
All,
I have the task of separating our AD into 2 domains due to selling one of
our companies off. Unfortunately, one of the SQL 2000 servers belongs to this
company and that needs to be moved to the new domain.
The machine in question is a windows 2003 server running SQL server 2000
sp3a. There are 3 databases on the machine, and there are domain accounts
that have permission to 2 of them.
The project will include creating the new domain and creating a trust
between them so that I can migrate user accounts with SID history, for
Exchange reasons.
How would I be able to move the server to the new domain? Do I just use the
Active Directory Migration Tool to move the server to the domain after the
user accounts have been moved, then assign the new domain user accounts to
the databases?
Any help would be appreciated
Thanks
Andoni
"Andoni" <Andoni@.discussions.microsoft.com> wrote in message
news:D3F1B0F8-53BA-43DB-8EB3-6A1E5C40AE33@.microsoft.com...
> How would I be able to move the server to the new domain? Do I just use
> the
> Active Directory Migration Tool to move the server to the domain after the
> user accounts have been moved, then assign the new domain user accounts to
> the databases?
After you migrate everything with ADMT, bounce the server into the new
domain, reset the service account and I do not believe you need to do
anything with login's based on domain accounts because they are sid based.
|||Hi Jason,
I have migrated the server, the user accounts were migrated beforehand. By
reset service account do you mean if SQL runs under a domain account? Also,
In the enterprise manager under security/logins, it's still showing domain
users in the old domain instead of the new one. will i need to create new
domain users?
thanks
A
"jason" wrote:
> "Andoni" <Andoni@.discussions.microsoft.com> wrote in message
> news:D3F1B0F8-53BA-43DB-8EB3-6A1E5C40AE33@.microsoft.com...
>
> After you migrate everything with ADMT, bounce the server into the new
> domain, reset the service account and I do not believe you need to do
> anything with login's based on domain accounts because they are sid based.
>
sql
I have the task of separating our AD into 2 domains due to selling one of
our companies off. Unfortunately, one of the SQL 2000 servers belongs to this
company and that needs to be moved to the new domain.
The machine in question is a windows 2003 server running SQL server 2000
sp3a. There are 3 databases on the machine, and there are domain accounts
that have permission to 2 of them.
The project will include creating the new domain and creating a trust
between them so that I can migrate user accounts with SID history, for
Exchange reasons.
How would I be able to move the server to the new domain? Do I just use the
Active Directory Migration Tool to move the server to the domain after the
user accounts have been moved, then assign the new domain user accounts to
the databases?
Any help would be appreciated
Thanks
Andoni
"Andoni" <Andoni@.discussions.microsoft.com> wrote in message
news:D3F1B0F8-53BA-43DB-8EB3-6A1E5C40AE33@.microsoft.com...
> How would I be able to move the server to the new domain? Do I just use
> the
> Active Directory Migration Tool to move the server to the domain after the
> user accounts have been moved, then assign the new domain user accounts to
> the databases?
After you migrate everything with ADMT, bounce the server into the new
domain, reset the service account and I do not believe you need to do
anything with login's based on domain accounts because they are sid based.
|||Hi Jason,
I have migrated the server, the user accounts were migrated beforehand. By
reset service account do you mean if SQL runs under a domain account? Also,
In the enterprise manager under security/logins, it's still showing domain
users in the old domain instead of the new one. will i need to create new
domain users?
thanks
A
"jason" wrote:
> "Andoni" <Andoni@.discussions.microsoft.com> wrote in message
> news:D3F1B0F8-53BA-43DB-8EB3-6A1E5C40AE33@.microsoft.com...
>
> After you migrate everything with ADMT, bounce the server into the new
> domain, reset the service account and I do not believe you need to do
> anything with login's based on domain accounts because they are sid based.
>
sql
Moving SQL Server to a new domain
All,
I have the task of separating our AD into 2 domains due to selling one of
our companies off. Unfortunately, one of the SQL 2000 servers belongs to this
company and that needs to be moved to the new domain.
The machine in question is a windows 2003 server running SQL server 2000
sp3a. There are 3 databases on the machine, and there are domain accounts
that have permission to 2 of them.
The project will include creating the new domain and creating a trust
between them so that I can migrate user accounts with SID history, for
Exchange reasons.
How would I be able to move the server to the new domain? Do I just use the
Active Directory Migration Tool to move the server to the domain after the
user accounts have been moved, then assign the new domain user accounts to
the databases?
Any help would be appreciated
Thanks
Andoni"Andoni" <Andoni@.discussions.microsoft.com> wrote in message
news:D3F1B0F8-53BA-43DB-8EB3-6A1E5C40AE33@.microsoft.com...
> How would I be able to move the server to the new domain? Do I just use
> the
> Active Directory Migration Tool to move the server to the domain after the
> user accounts have been moved, then assign the new domain user accounts to
> the databases?
After you migrate everything with ADMT, bounce the server into the new
domain, reset the service account and I do not believe you need to do
anything with login's based on domain accounts because they are sid based.|||Hi Jason,
I have migrated the server, the user accounts were migrated beforehand. By
reset service account do you mean if SQL runs under a domain account? Also,
In the enterprise manager under security/logins, it's still showing domain
users in the old domain instead of the new one. will i need to create new
domain users?
thanks
A
"jason" wrote:
> "Andoni" <Andoni@.discussions.microsoft.com> wrote in message
> news:D3F1B0F8-53BA-43DB-8EB3-6A1E5C40AE33@.microsoft.com...
> >
> > How would I be able to move the server to the new domain? Do I just use
> > the
> > Active Directory Migration Tool to move the server to the domain after the
> > user accounts have been moved, then assign the new domain user accounts to
> > the databases?
> After you migrate everything with ADMT, bounce the server into the new
> domain, reset the service account and I do not believe you need to do
> anything with login's based on domain accounts because they are sid based.
>
I have the task of separating our AD into 2 domains due to selling one of
our companies off. Unfortunately, one of the SQL 2000 servers belongs to this
company and that needs to be moved to the new domain.
The machine in question is a windows 2003 server running SQL server 2000
sp3a. There are 3 databases on the machine, and there are domain accounts
that have permission to 2 of them.
The project will include creating the new domain and creating a trust
between them so that I can migrate user accounts with SID history, for
Exchange reasons.
How would I be able to move the server to the new domain? Do I just use the
Active Directory Migration Tool to move the server to the domain after the
user accounts have been moved, then assign the new domain user accounts to
the databases?
Any help would be appreciated
Thanks
Andoni"Andoni" <Andoni@.discussions.microsoft.com> wrote in message
news:D3F1B0F8-53BA-43DB-8EB3-6A1E5C40AE33@.microsoft.com...
> How would I be able to move the server to the new domain? Do I just use
> the
> Active Directory Migration Tool to move the server to the domain after the
> user accounts have been moved, then assign the new domain user accounts to
> the databases?
After you migrate everything with ADMT, bounce the server into the new
domain, reset the service account and I do not believe you need to do
anything with login's based on domain accounts because they are sid based.|||Hi Jason,
I have migrated the server, the user accounts were migrated beforehand. By
reset service account do you mean if SQL runs under a domain account? Also,
In the enterprise manager under security/logins, it's still showing domain
users in the old domain instead of the new one. will i need to create new
domain users?
thanks
A
"jason" wrote:
> "Andoni" <Andoni@.discussions.microsoft.com> wrote in message
> news:D3F1B0F8-53BA-43DB-8EB3-6A1E5C40AE33@.microsoft.com...
> >
> > How would I be able to move the server to the new domain? Do I just use
> > the
> > Active Directory Migration Tool to move the server to the domain after the
> > user accounts have been moved, then assign the new domain user accounts to
> > the databases?
> After you migrate everything with ADMT, bounce the server into the new
> domain, reset the service account and I do not believe you need to do
> anything with login's based on domain accounts because they are sid based.
>
Subscribe to:
Posts (Atom)