Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

in this query the month field repeats in my ssrs report. I want to show distinct months.
I want to show all the details month wise. how to do kindly help.
SQL
SELECT  
	DATENAME(MONTH, Date) AS MONTH, GatePassNo, Product_name, 
	SerialNo, Customer_Name, Customer_Location, 
	count( (CASE WHEN "Status" = 'Repaired by Vendor' THEN "Status" END)) as "Repaired",
	count( (CASE WHEN "Status" = 'Sent to Vendor for Repair' THEN "Status" END)) as "Pending",
	count( (CASE WHEN "Status" = 'Replaced with FSPL Inventory and Sent for Repair'or "Status" = 'Replaced with Onsite Inventory and Sent to Vendor'THEN "Status" END)) as "Replaced"
FROM            
	Product_Details
WHERE Customer_Name in (@Customer_Name) and Customer_Location in (@Customer_Location)
GROUP BY GatePassNo, Product_name, SerialNo, Customer_Name, Customer_Location, DATENAME(MONTH, Date)
Posted
Updated 10-Feb-15 1:24am
v2
Comments
ZurdoDev 10-Feb-15 7:35am    
Did you add the keyword DISTINCT?
Member 10578683 10-Feb-15 8:21am    
ya after that also it is not coming
ZurdoDev 10-Feb-15 8:23am    
We need way more information before we can help you.
Member 10578683 11-Feb-15 1:53am    
I want to write a nested query from the above query so that i will get all the details according to month. month should be the parent group and all details comes as child group. don't know how to design the query. kindly help
Member 10578683 11-Feb-15 2:07am    
Month GatePassNo Paroduct_nmae SerialNo Pending Repaired Replace
January qqq RAM rttt 1 0 1
January rrr Mouse hhhh 2 1 1
February aaa SMPS aaa 0 1 1
Like this it is coming but i want
January qqq RAM rttt 1 0 1
rrr Mouse hhhh 2 1 1
February aaa SMPS aaa 0 1 1
like this it should come

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900