 |
|
 |
|
Next: clustering
|
| Author |
Message |
External

Since: Apr 14, 2008 Posts: 1
|
(Msg. 1) Posted: Mon Apr 14, 2008 10:40 pm
Post subject: Help w/query pls Archived from groups: microsoft>public>access>queries, others (more info?)
|
|
|
Hi,
I need to display on a monthly basis the policies sold showing the results
in a row from
their start date to the end date based on the following data:
policy_cost, date_start and date_end
Column one should display the first month (date_start) and the n column the
last month (date_end).
The difference between date_start and date_end vary from 1 month to 48.
Select Sum(Case
When Datepart(mm,date_start) = 1 then
policy_cost/Datediff(mm,date_start,date_end)) end as Jan,
..
Sum(Case
When Datepart(mm,date_start) = 12 then
policy_cost/Datediff(mm,date_start,date_end)) end as Dic
From table
Where datepart(yyyy, date_start) = 2005 **revenues with start date 2005**
The above query returns the first 12 months, how to display the rest of the
months considering
that the last policy can have date_start late December and date_end 48
months later?
Any help is highly appreciated.
Olga >> Stay informed about: Help w/query pls |
|
| Back to top |
|
 |  |
External

Since: Jan 10, 2008 Posts: 129
|
(Msg. 2) Posted: Tue Apr 15, 2008 9:45 am
Post subject: RE: Help w/query pls [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Olga,
are you doing this in Access or in SQL Server.
If you are using Access as your front-end to either an Access or SQL Server
backend, you should be able to create a Crosstab query that uses the
DateDiff("m", Date_Start, Date_End) as the column header. If you want to
make sure you have exactly 48 column headers(one for every month for the next
4 years), you might have to define them manually using the ColumnHeadings
property of the cross tab query. Instead of using the datediff as the column
header, you might want to use something like: Format(Date_End, "yyyy-mm")
HTH
Dale
--
Don''t forget to rate the post if it was helpful!
email address is invalid
Please reply to newsgroup only.
"Olga" wrote:
> Hi,
>
> I need to display on a monthly basis the policies sold showing the results
> in a row from
>
> their start date to the end date based on the following data:
>
> policy_cost, date_start and date_end
>
>
>
> Column one should display the first month (date_start) and the n column the
> last month (date_end).
>
> The difference between date_start and date_end vary from 1 month to 48.
>
>
>
> Select Sum(Case
>
> When Datepart(mm,date_start) = 1 then
> policy_cost/Datediff(mm,date_start,date_end)) end as Jan,
>
> .
>
> Sum(Case
>
> When Datepart(mm,date_start) = 12 then
> policy_cost/Datediff(mm,date_start,date_end)) end as Dic
>
> From table
>
> Where datepart(yyyy, date_start) = 2005 **revenues with start date 2005**
>
>
>
> The above query returns the first 12 months, how to display the rest of the
> months considering
>
> that the last policy can have date_start late December and date_end 48
> months later?
>
> Any help is highly appreciated.
>
> Olga
> >> Stay informed about: Help w/query pls |
|
| Back to top |
|
 |  |
| Related Topics: | Trying to cut down query times - I have a query that is based on two other queries that are based on tables in a database. All of the queries that are used for this final query use grouping and totals. In the application I am making, I need to choose a date range to select the subset....
How to do updates upon the query results - Hello, I've run a complex SELECT statement combined of the several tables, which returns me: MemberID MemberName CurrentWeightAvailableOn010108 NeedsToHaveWeightOnDate Modifier(NeedsToHaveWeight-CurrentWeightAvailable) 1 John Doe ...
singleton query agains OLAP based model? - Hi, I have created a decision tree DM model from a cube. now I try the singleton query, but how to create the query???? the only samples I found works against an RDBMS model. so I'm not sure how to write my query: SELECT flattened [Test Dec..
Running a SQL query - table include FROM and TO columns - I am trying to export some calendar data from a sql table. This table has 2 column names "from" and "to" for the time range of the appointment. When I run the sql query: select date, from, to, act_code, mat_code, clt_code, notes, de...
Collation Problem any help - Hello all : My problem is like the following I have an online databse with a latin collation, this database is using ntext and nvarchar values that was with our previous admin ok the problem is in the data is stored should use another collation (the... |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|