Viewing 10 posts - 1 through 10 (of 10 total)
declare @tab table
(
id int identity(1,1),
names varchar(100),
dates datetime
)
insert into @tab(names,dates)
values('student1',DATEADD(day,10,getdate()))
,('student1',DATEADD(day,5,getdate()))
,('student1',DATEADD(day,15,getdate()))
,('student2',DATEADD(day,10,getdate()))
,('student2',DATEADD(day,5,getdate()))
,('student3',DATEADD(day,11,getdate()))
,('student4',DATEADD(day,15,getdate()))
,('student4',DATEADD(day,10,getdate()))
select id,names,dates,inc=pt.inc
from
@tab t
cross apply
(
select [inc]= COUNT(1)+1 from @tab pt where pt.id <t.id and...
December 7, 2010 at 4:30 am
Hi,
This is another option, if u feel ur Treatment id increments by 11 for each new record.
SELECT *
FROM Patient P
JOIN
(
SELECT T1.PatientID,[TreatmentCount]=COUNT(1) from Treatment T1
LEFT OUTER join Treatment T2 on...
September 29, 2010 at 12:36 am
This one is really a good solution. Thanks:-)
May 13, 2010 at 6:44 am
Hi this would also help u
create table #tmp
(
Sequences tinyint,
Product varchar(100),
Timing datetime,
Price float
)
insert into #tmp(SEQUENCEs,PRODUCT,TIMing,PRICE)
select 2,'Spoon1','2010-05-05 08:31:01.000',80.00
union all
select 3,'Spoon1','2010-05-05...
May 7, 2010 at 10:17 pm
hi everyone,
After creating server side trace and logging the errors to file, and using
SELECT *
FROM ::fn_trace_gettable('C:\ErrorTrace.trc', DEFAULT)
but the problem is Textdata column shows like "Invalid object name '%.*ls'.",...
April 21, 2010 at 4:10 am
Thanks for your reply. Helped me a lot. would be implementing server -side trace and appending it to file.
April 20, 2010 at 7:11 am
Yes all columns except the column which is added in aggregate fn.
July 23, 2008 at 11:16 pm
Hi Pal,
try this
IF EXISTS
(SELECT * FROM SYS.OBJECTS
WHERE OBJECT_ID =
OBJECT_ID(N'[DBO].[MYTABLE]')
AND TYPE IN (N'U'))
DROP TABLE [DBO].[MYTABLE]
GO
CREATE...
July 23, 2008 at 5:33 am
HI,
the problem is that u have not added all columns except the column name inside count function under group by
.The rule is all columns except the columns related to aggregate...
July 23, 2008 at 5:22 am
Viewing 10 posts - 1 through 10 (of 10 total)