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 #Person (personID int, FirstName varchar(20), LastName varchar(20),
Phone varchar(12), Age int)

insert #Person values(1, 'first1', 'last1', 'phone1', 1)
insert #Person values(2, 'first2', 'last2', 'phone2', 2)

Select case when
   grouping(personid) = 0 And Grouping(firstname) = 1 And
   Grouping(lastname) = 1 And grouping(phone) = 1 And
   Grouping(age) = 1
       then 'PersonID'
   when
   grouping(personid) = 1 And Grouping(firstname) = 0 And
   Grouping(lastname) = 1 And grouping(phone) = 1 And
   Grouping(age) = 1
       then 'FirstName'
   when
   grouping(personid) = 1 And Grouping(firstname) = 1 And
   Grouping(lastname) = 0 And grouping(phone) = 1 And
   Grouping(age) = 1
       then 'LastName'
   when
   grouping(personid) = 1 And Grouping(firstname) = 1 And
   Grouping(lastname) = 1 And grouping(phone) = 0 And
   Grouping(age) = 1
       then 'Phone'
   when
   grouping(personid) = 1 And Grouping(firstname) = 1 And
   Grouping(lastname) = 1 And grouping(phone) = 1 And
   Grouping(age) = 0
       then 'Age'
   end as FieldName,
   case when
   grouping(personid) = 0 And Grouping(firstname) = 1 And
   Grouping(lastname) = 1 And grouping(phone) = 1 And
   Grouping(age) = 1
       then ltrim(str(personid))
   when
   grouping(personid) = 1 And Grouping(firstname) = 0 And
   Grouping(lastname) = 1 And grouping(phone) = 1 And
   Grouping(age) = 1
       then firstname
   when
   grouping(personid) = 1 And Grouping(firstname) = 1 And
   Grouping(lastname) = 0 And grouping(phone) = 1 And
   Grouping(age) = 1
       then LastName
   when
   grouping(personid) = 1 And Grouping(firstname) = 1 And
   Grouping(lastname) = 1 And grouping(phone) = 0 And
   Grouping(age) = 1
       then Phone
   when
   grouping(personid) = 1 And Grouping(firstname) = 1 And
   Grouping(lastname) = 1 And grouping(phone) = 1 And
   Grouping(age) = 0
       then Ltrim(Str(Age))
   end as FieldValue
from #Person
group by personid, firstname, lastname, phone, age
with cube
having (grouping(personid) = 0 And Grouping(firstname) = 1 And
   Grouping(lastname) = 1 And grouping(phone) = 1 And
   Grouping(age) = 1)
   or
   (grouping(personid) = 1 And Grouping(firstname) = 0 And
   Grouping(lastname) = 1 And grouping(phone) = 1 And
   Grouping(age) = 1)
   or
   (grouping(personid) = 1 And Grouping(firstname) = 1 And
   Grouping(lastname) = 0 And grouping(phone) = 1 And
   Grouping(age) = 1)
   or
   (grouping(personid) = 1 And Grouping(firstname) = 1 And
   Grouping(lastname) = 1 And grouping(phone) = 0 And
   Grouping(age) = 1)
   or
   (grouping(personid) = 1 And Grouping(firstname) = 1 And
   Grouping(lastname) = 1 And grouping(phone) = 1 And
   Grouping(age) = 0)


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.