home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 18,933 of 19,505   
   migurus to All   
   how many new IDs participated   
   13 Aug 13 18:43:44   
   
   From: migurus@yahoo.com   
      
   I have a series of Customer ID / Date records showing participation of   
   customers on the daily basis. I need to find out how many new customers   
   participated each day.   
      
   To illustrate:   
   declare	@T TABLE (   
   	ID	int		not null   
   ,	DT	date	not null   
   )   
      
   insert into @T values   
   (505500,' 2013-08-07'),   
   (144998,' 2013-08-07'),   
   (505500,' 2013-08-08'),   
   (144998,' 2013-08-08'),   
   (332551,' 2013-08-09'),   
   (505500,' 2013-08-09'),   
   (332551,' 2013-08-09'),   
   (144998,' 2013-08-09'),   
   (505500,' 2013-08-12'),   
   (144998,' 2013-08-12'),   
   (505500,' 2013-08-13'),   
   (144998,' 2013-08-13'),   
   (650707,' 2013-08-13');   
      
   I need an output that shows:   
   2013-08-07	2   
   2013-08-08	0   
   2013-08-09	2   
   2013-08-12	0   
   2013-08-13	1   
      
   Just to clarify myself - same two ids were there on 8th, so we got 0 for 8th,   
   then two new ids out of four records on 9th, that is why 2 for 9th etc...   
      
   Any ideas? I was trying to self-join but can not quite wrap my brain around it.   
   Thanks in advance.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca