| Author |
Topic |
|
fengfeng
Yak Posting Veteran
64 Posts |
Posted - 2011-03-24 : 21:35:15
|
| I want to query a table that contains campaign names and there is a start date field and the other fields are data.How can I choose campaign information for all campaigns but I just want the first 7 days of any given campaign and they all have different start dates? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-03-24 : 22:18:23
|
What do you mean by "first 7 days" ? with relative to what date ?or campaigns that started in the last 7 days from today ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
fengfeng
Yak Posting Veteran
64 Posts |
Posted - 2011-03-25 : 09:05:03
|
quote: Originally posted by khtan What do you mean by "first 7 days" ? with relative to what date ?or campaigns that started in the last 7 days from today ? KH[spoiler]Time is always against us[/spoiler]
I mean the campaign table has a field called start date, can I say something like sum(sales) of the first 7 days of all campaigns beginning on their start date, group by campaigns, sales. |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-03-25 : 09:23:28
|
| Do you have another date field to compare to the start date?JimEveryday I learn something that somebody else already knew |
 |
|
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2011-03-25 : 12:13:00
|
| just a guess, it seems that your requirements can be fulfilled by Order by Clause ... in case if you are looking for summation of all first seven days compaigns then you may also need to introduce a column composed of Row_Number function to determine first seven days for all campaigns and then use that data set for required purpose.CheersMIK |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-03-25 : 22:25:11
|
i think it will be much easier for us to understand your requirement if you can1. post the DDL of your table2. post some sample data3. show us the expected resultplease refer to this http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
fengfeng
Yak Posting Veteran
64 Posts |
Posted - 2011-03-28 : 11:38:29
|
| The output would look like: Month 1st 7 days Line_code Views Clicks Views ClicksThe code I have for the entire month would be:SELECT line_code, Views, SalesFROM broadwayWHERE date BETWEEN '2011-02-01 00:00:00' AND '2011-02-28 00:00:00'The part I'm having trouble with is , for those corresponding line_code, I want to see just the first 7 days of the line code only if it has views of over 100.I could just do date between 2011-02-01 and 2011-02-07 but then some line code dont start having data on 02-01. Is there a way to specify to count the first 7 days of the month when the data actually starts? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-03-28 : 20:45:56
|
You are not making it easier for us to help you. Please refer to my last post on 03/25/2011 : 22:25:11.Looking at your other thread, it seems that you are not using Microsoft SQL Server ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|