Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 empname value should not come in multipletimes

Author  Topic 

kond.mohan
Posting Yak Master

213 Posts

Posted - 2013-05-31 : 10:09:52
i have written one query for Static report purpose. empname is same for multiple amounts.we need to show the empname for once for different amounts.
report coming ritht now
amar bahadusingh 9000
amar bahadusingh 80
amar bahadusingh 645455
amar bahadusingh 7843

expected format
amar bahadusingh 9000
80
645455
7843

sameple query .
Amar BahadurSingh Nagpur Nagpur Jain Lime & Hardware (L.F) - NSD Wall Putty 261807.00
Amar BahadurSingh Nagpur Nagpur Pyramid Incorporation (L.Finish) - Wall Putty 0.00
Amar BahadurSingh Nagpur Nagpur Shoeb Khan (L.F) - NSD Wall Putty 23850.00
Amar BahadurSingh Nagpur Nagpur SIMON THOMAS VARGHESE Wall Putty 97200.00
Amar BirPalta Hyderabad Hyderabad HO Samples Adhesive 0.00
Amar BirPalta Hyderabad Hyderabad HO Samples Application Tools 0.00
Amar BirPalta Hyderabad Hyderabad HO Samples GROUT 0.00
Amar BirPalta Hyderabad Hyderabad HO Samples LATEX 0.00
Amar BirPalta Hyderabad Hyderabad HO Samples STONE CARE 0.00

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-05-31 : 10:16:30
quote:
Originally posted by kond.mohan

i have written one query for Static report purpose. empname is same for multiple amounts.we need to show the empname for once for different amounts.
report coming ritht now
amar bahadusingh 9000
amar bahadusingh 80
amar bahadusingh 645455
amar bahadusingh 7843

expected format
amar bahadusingh 9000
80
645455
7843

sameple query .
Amar BahadurSingh Nagpur Nagpur Jain Lime & Hardware (L.F) - NSD Wall Putty 261807.00
Amar BahadurSingh Nagpur Nagpur Pyramid Incorporation (L.Finish) - Wall Putty 0.00
Amar BahadurSingh Nagpur Nagpur Shoeb Khan (L.F) - NSD Wall Putty 23850.00
Amar BahadurSingh Nagpur Nagpur SIMON THOMAS VARGHESE Wall Putty 97200.00
Amar BirPalta Hyderabad Hyderabad HO Samples Adhesive 0.00
Amar BirPalta Hyderabad Hyderabad HO Samples Application Tools 0.00
Amar BirPalta Hyderabad Hyderabad HO Samples GROUT 0.00
Amar BirPalta Hyderabad Hyderabad HO Samples LATEX 0.00
Amar BirPalta Hyderabad Hyderabad HO Samples STONE CARE 0.00

This is easier to do on the reporting side - in SSRS, for example, if that is what you are using. If you want to do this in SQL,
SELECT
CASE WHEN RN = 1 THEN [name] ELSE '' END AS [Name],
Amount
FROM
(SELECT
[name],[amount],
ROW_NUMBER() OVER (PARTITION BY [name] ORDER BY amount) AS RN -- order by whatever criteria you want
FROM
YourTable
)s ORDER BY RN -- or some other criteria
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-06-01 : 05:43:42
In reporting side its just a matter of setting property Hide Duplicates for textbox showing name

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

- Advertisement -