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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 QUERY

Author  Topic 

WoodHouse
Posting Yak Master

211 Posts

Posted - 2009-09-22 : 01:52:04
Hi

We have table data like....36 months data for each part_number..
example

PArt_number month data
aaa 1 10
aaa 2 20
aaa 3 30
... ... ...
... ... ...
... ... ...
aaa 36 360
bbb 1 10
bbb 2 20
bbb 3 30
... ... ...
... ... ...
... ... ...
bbb 36 360

I need the query each part number first 12 month details....
(like......Part_number, month_id, data)
please help on this.........
thanks


webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-22 : 02:00:52
select
Part_number,
month_id,
data
from table
where month_id between 1 and 12
order by Part_number,month_id


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

WoodHouse
Posting Yak Master

211 Posts

Posted - 2009-09-22 : 02:08:23
thanks webfred

i have one more doubt ...pls help

CREATE VIEW vIO_DF_Forecast_Data
WITH SCHEMABINDING
AS

SELECT a.period ,
a.sku ,
a.period_id,
model_id ,
(a.forecast_data+b.intelligence+b.adjustments)total_forecast
FROM io_cm_forecast_data a,
io_df_x_intelligence_forcaste b
WHERE a.sku = b.sku
AND a.period_id = b.period_id


CREATE CLUSTERED INDEX idx_vIO_DF_Forecast
ON vIO_DF_Forecast_Data (sku, period_id)


for above view i can't able to create index on that....
Go to Top of Page

WoodHouse
Posting Yak Master

211 Posts

Posted - 2009-09-22 : 02:18:45
Thanks i have done

alter VIEW dbo.vIO_DF_Forecast_Data
WITH SCHEMABINDING
AS

SELECT a.period ,
a.sku ,
a.period_id,
model_id ,
(a.forecast_data+b.intelligence+b.adjustments)total_forecast
FROM dbo.io_cm_forecast_data a,
dbo.io_df_x_intelligence_forcaste b
WHERE a.sku = b.sku
AND a.period_id = b.period_id
AND a.period_id between 1 and 12
--order by a.sku ,a.period_id


CREATE UNIQUE CLUSTERED INDEX idx_vIO_DF_Forecast
ON vIO_DF_Forecast_Data (sku, period_id)
Go to Top of Page
   

- Advertisement -