Viewing 15 posts - 1,996 through 2,010 (of 3,543 total)
SELECT TOP 5 c_id
FROM (SELECT DISTINCT o_date, c_id FROM @table) a
ORDER BY o_date DESC, c_id ASC
January 23, 2006 at 2:22 am
![]() | Are you worried about readability or performance? |
Both It depends on...
January 20, 2006 at 7:59 am
Is it top 5 per date?
if so then
SELECT a.o_date, a.c_id
FROM (SELECT o_date, c_id FROM GROUP BY o_date, c_id) a
WHERE a.c_id IN
(SELECT TOP 5 b.c_id
FROM ...
January 20, 2006 at 7:10 am
or
STUFF(STUFF([string],PATINDEX('%[0-9]PT%',[string])+1,255,''),1,PATINDEX('% [.0-9]%PT%',[string]),'')
January 20, 2006 at 6:53 am
Agree not enough info and too many ambiguities.
My guess would be
DECLARE @date datetime
SELECT @date = MAX([date])
FROM
WHERE [date] < @currentdate...
January 20, 2006 at 3:29 am
![]() | David is great in guessing what people want.... |
Thanks Jesper, I owe it to my Ouija board
January 20, 2006 at 2:34 am
Not me personally
but if you search this forum there will be plenty of advice
two threads to get you going
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=5834
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=17678
January 19, 2006 at 8:15 am
DECLARE @max-2 int, @id int, @sql nvarchar(1000)
CREATE TABLE #temp1([ID] int IDENTITY(1,1), COLUMN_NAME sysname)
INSERT INTO #temp1(COLUMN_NAME) SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'TEST' AND COLUMN_NAME LIKE 'Ext%'
SET...
January 19, 2006 at 6:44 am
How about this then
SELECT MIN(CODE) AS
FROM (SELECT TOP 3 CODE
FROM
WHERE ENDDATE < @datein
ORDER BY CODE DESC) x...
January 18, 2006 at 7:53 am
How about
SELECT b.CODE
FROM a
INNER JOIN b ON b.[ID] = a.[ID]-3
WHERE @datein BETWEEN a.STARTDATE AND a.ENDDATE
or have I got this completely wrong
January 18, 2006 at 6:58 am
Not sure what you mean by match prob. Can you post ddl and sample data plus expected output?
I would write your query like this
select ssg.Name + ' ' + supt.Name ...
January 17, 2006 at 7:13 am
DECLARE @months int
SET @months = (YEAR(GETDATE()) * 12) + MONTH(GETDATE())
SELECT [Year],[Month],SUM(ViewCount) AS Downloads
FROM FileViews
WHERE ([Year] * 12) + [Month] BETWEEN @months-2 AND @months
GROUP BY [Year],...
January 17, 2006 at 6:52 am
Depending on what your 'Upload data from txt file to the table' process is you caould put the file exists test, truncate and load all in one step.
Or check the...
January 17, 2006 at 2:23 am
Thank you Steve.
Must read the questions more carefully, the question meant property fields
and never trust MS documentation http://msdn2.microsoft.com/en-us/library/ms210363.aspx
January 16, 2006 at 8:30 am
Viewing 15 posts - 1,996 through 2,010 (of 3,543 total)