Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools


Click here to copy the following block
create table #n_facts (FactID int , Code char(1))
go
insert into #n_facts values (1 , 'X' )
insert into #n_facts values (1 , 'Y' )
insert into #n_facts values (1 , 'Z' )
insert into #n_facts values (2 , 'A' )
insert into #n_facts values (2 , 'B' )
insert into #n_facts values (2 , 'C' )
insert into #n_facts values (3 , 'E' )
insert into #n_facts values (3 , 'F' )
insert into #n_facts values (3 , 'G' )
insert into #n_facts values (4 , 'X' )
insert into #n_facts values (4 , 'Y' )
insert into #n_facts values (4 , 'Z' )
go
select * from #n_facts


select min(c1.factid) as factid, c1.code, c2.code, c3.code
from
   (select t1.factid, t1.code
   from #n_facts t1
   where (select count(*) from #n_facts t2
       where t2.factid = t1.factid and t2.code <= t1.code) = 1) c1
join
   (select t1.factid, t1.code
   from #n_facts t1
   where (select count(*) from #n_facts t2
       where t2.factid = t1.factid and t2.code <= t1.code) = 2) c2
join
   (select t1.factid, t1.code
   from #n_facts t1
   where (select count(*) from #n_facts t2
       where t2.factid = t1.factid and t2.code <= t1.code) = 3) c3
on c3.factid = c2.factid
on c2.factid = c1.factid
group by c1.code, c2.code, c3.code
order by 1


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.