SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to write a query for this
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ramya888
Starting Member

India
11 Posts

Posted - 07/23/2013 :  03:00:46  Show Profile  Reply with Quote
i am getting a output like this,

lname cperson desig cno extnno faxno mobilno location
ZZZZZ arun exe 2 456 787 98989 mumbai
zzzzz ram MNG 3 454 909 89878 mumbai
zzzzz kk Smng 4 343 888 78987 mumbai

but i want like this
lname cperson desig cno extnno faxno mobilno location
ZZZZZ arun exe 2 456 787 98989 mumbai
ram MNG 3 454 909 89878
kk Smng 4 343 888 78987

here lname and location there is a repetation,so i want to show only one lname records and one location records,because it has same name which is repeting in the records,is there any way to do like this

Ramy

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 07/23/2013 :  03:59:35  Show Profile  Reply with Quote
This property is called suppress duplicates or hide duplicates and is available on most of the front end reporting tools. You can find this property within textbox properties in SSRS

Doing this in SQL is ugly as its a presentation issue.
However if you really have no other choice use the below


SELECT CASE WHEN Seq=1 THEN lname ELSE '' END AS lname,
cperson, desig,cno, extnno, faxno, mobilno, location
FROM
(
SELECT ROW_NUMBER() OVER (PARTITION BY lnamefield ORDER BY cno) AS RN,...
... Rest of your query
)t


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22754 Posts

Posted - 07/23/2013 :  07:57:28  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
quote:
Originally posted by ramya888

i am getting a output like this,

lname cperson desig cno extnno faxno mobilno location
ZZZZZ arun exe 2 456 787 98989 mumbai
zzzzz ram MNG 3 454 909 89878 mumbai
zzzzz kk Smng 4 343 888 78987 mumbai

but i want like this
lname cperson desig cno extnno faxno mobilno location
ZZZZZ arun exe 2 456 787 98989 mumbai
ram MNG 3 454 909 89878
kk Smng 4 343 888 78987

here lname and location there is a repetation,so i want to show only one lname records and one location records,because it has same name which is repeting in the records,is there any way to do like this

Ramy


Where do you want to show data? If you use reporting tool, use Suppress if duplicate option

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000