Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
lkritchey
Starting Member
6 Posts |
Posted - 2009-06-15 : 09:59:15
|
| I'm not positive if this is the right forum for this, so if it should be moved, please feel free to do so. I'm familiar with the basics - but not advanced with this, so please bear with me :)We have a database with a month table, where each month has an ID related to a month label (i.e. 1 = Jan 06, 2 = Feb 06, 3 = Mar 06, etc). This will always be in order of date and numerical value, starting from January 2006. We have another table with a FK to the month table. It has the requisition information with a related MonthID (i.e. the 1, 2, 3 I mentioned above). I need to select all month label values that are related to the subset of requisition month ids. For example, say our dataset starts at Mar 06, with a span of 25 months. I need to get all month labels which relate to month ID 3 (Mar 06) continuing for 25 months. I also need to get these values in order. I know how to use SELECT statements with ORDER BY, but I am having trouble putting all of these requirements together.Any help with getting the correct syntax of the SQL statement is much appreciated!Thanks in advance for your help!-Laura |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-15 : 10:19:09
|
Please post your table layout(s) and proper sample data, together with expected output. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
lkritchey
Starting Member
6 Posts |
Posted - 2009-06-15 : 11:07:29
|
| Here are the relevant tables and fields. Sorry for forgetting to post it!TABLE NAME: SummarySingleFIELDS (Sample Data)MonthYearID_pk_fk (1, 2, 3 - FK / PK)MetricHeaderID_pk_fk (1, 2, 3 - FK / PK)ReqDmdFills (48)SMA (57)VolTimeToEnterReq (845)TimeToEnterReq (55)ResponseTimeDelayed (67)UnfilledCustomerOrders (356)TABLE NAME: MonthYearFIELD NAMES:MonthYearID (1, 2, 3)MonthYearText (Jan 06, Feb 06, Mar 06 - above referred to as month label)MonthYear (January 2006, February 2006, March 2006) |
 |
|
|
lkritchey
Starting Member
6 Posts |
Posted - 2009-06-15 : 11:11:00
|
| Expected Output is as follows: Assuming Dataset began with Mar 06, the populated dataset would hold the following (25 months):Mar 06, Apr 06, May 06, Jun 06, Jul 06, Aug 06, Sep 06, Oct 06, Nov 06, Dec 06, Jan 07, Feb 07, Mar 07, Apr 07, May 07, Jun 07, Jul 07, Aug 07, Sep 07, Oct 07, Nov 07, Dec 07, Jan 08, Feb 08, Mar 08, Apr 08 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-15 : 14:07:55
|
| you need only month labels? or you also need some summary figures under each? |
 |
|
|
lkritchey
Starting Member
6 Posts |
Posted - 2009-06-15 : 14:18:29
|
| I'm using this to automate a metrics presentation in ppt. This particular chart is only composed of Volume of Requisition Demands per month and the Average Volume of Requisition Demands. I already have taken in a dataset of the requisition demand values and plotted out the chart for each month. For this part, I only need the month labels that correspond with the requisition demand values that are plotted on the chart. Many other summary figures are used - but this chart is only composed of the two values I listed above, along with the corresponding month labels. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-15 : 14:22:54
|
| so what you need is to cross tab month names?? |
 |
|
|
lkritchey
Starting Member
6 Posts |
Posted - 2009-06-15 : 14:30:47
|
| Pretty much so, if i understand what you mean. I just need an ordered list of month labels that correspond with the month IDs within the specified 25 month span. |
 |
|
|
lkritchey
Starting Member
6 Posts |
Posted - 2009-06-15 : 16:05:22
|
| I think I am making this harder than it needs to be. I'm going to check out a SQL Statement that I think will work, and will write back to let you know if it is or is not the right solution. |
 |
|
|
|
|
|
|
|