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 2000 Forums
 Transact-SQL (2000)
 subqueries

Author  Topic 

nurul iza
Starting Member

17 Posts

Posted - 2006-02-19 : 22:08:05
hi all...
i'm nurul.i have one project that use sql server 2000 as my database and asp code to view the graph. i have a problem to view the graph that only view the 10 latest WW in my database. i create a stored procedure and it will select the top 10 but start from the last record.how should i do a subqueries to get the asc data after i desc it...any help??

above is my code:
CREATE PROCEDURE try AS
SELECT top 10 ( DATENAME(week,DATEADD(s, Create_Date, '19700101')) ) AS WW, count (id) AS Volume
FROM test
WHERE (Orig = 'SUPPORT') OR (Support = 'MFG') AND (Site = 'A')
GROUP BY DATENAME(week,DATEADD(s, Create_Date, '19700101'))
HAVING DATENAME(week,DATEADD(s, Create_Date, '19700101')) BETWEEN '1' AND '53'
ORDER BY DATENAME(week,DATEADD(s, Create_Date, '19700101')) desc
GO

<thanks>

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-02-19 : 22:11:53
[code]select *
from
(
-- Your original query here
SELECT top 10 ( DATENAME(week,DATEADD(s, Create_Date, '19700101')) ) AS WW, count (id) AS Volume
FROM test
WHERE (Orig = 'SUPPORT') OR (Support = 'MFG') AND (Site = 'A')
GROUP BY DATENAME(week,DATEADD(s, Create_Date, '19700101'))
HAVING DATENAME(week,DATEADD(s, Create_Date, '19700101')) BETWEEN '1' AND '53'
ORDER BY DATENAME(week,DATEADD(s, Create_Date, '19700101')) desc
) as a
order by WW[/code]

----------------------------------
'KH'

Time is always against us
Go to Top of Page

nurul iza
Starting Member

17 Posts

Posted - 2006-02-19 : 22:43:45
hi khtan...

thanks a lot 4 ur coding...it's can work..ur genius..

<thanks>
Go to Top of Page
   

- Advertisement -