Hi All,
I want to exclude the date column from my GROUP BY statement. I need to keep the date column as my filter applies to filtering a date range.
Is this Possible?
Any help would be appreciated.
<asp:SqlDataSource ID="calldata" runat="server" ConnectionString="<%$ ConnectionStrings:SupportConnection %>" SelectCommand="SELECT DISTINCT [clientName], [callType], [softwareType], [date] FROM [callData] WHERE (([clientName] LIKE '%' + @clientName + '%') AND ([softwareType] LIKE '%' + @softwareType + '%') AND ([callType] LIKE '%' + @callType + '%') AND ([date] >= Convert(datetime,@startDate)) AND ([date] <= Convert(datetime,@endDate))) GROUP BY [clientName], [callType], [softwareType], [date] ORDER BY [clientName] ASC" FilterExpression="softwareType LIKE '{0}%' AND callType LIKE '%{1}%' AND clientName LIKE '%{2}% AND ('{3}' = '' OR date >= '{3}') AND ('{4}' = '' OR date <= '{4}')" UpdateCommand="UPDATE [callData] SET [clientName] = @clientName, [callType] = @callType, [softwareType] = @softwareType, [date] = @date"
If you still need the date to show up on your results, you will have to aggregate it in order to be able to exclude it from the GROUP BY clause. Either MIN() MAX().
SELECT DISTINCT [clientName], [callType], [softwareType] FROM [callData] WHERE (([clientName] LIKE '%' + @clientName + '%') AND ([softwareType] LIKE '%' + @softwareType + '%') AND ([callType] LIKE '%' + @callType + '%') AND ([date] >= Convert(datetime,@startDate)) AND ([date] <= Convert(datetime,@endDate))) GROUP BY [clientName], [callType], [softwareType] ORDER BY [clientName] ASCor as previously statedSELECT DISTINCT [clientName], [callType], [softwareType], max([date]) max_date, min([date]) min_date FROM [callData] WHERE (([clientName] LIKE '%' + @clientName + '%') AND ([softwareType] LIKE '%' + @softwareType + '%') AND ([callType] LIKE '%' + @callType + '%') AND ([date] >= Convert(datetime,@startDate)) AND ([date] <= Convert(datetime,@endDate))) GROUP BY [clientName], [callType], [softwareType], [date] ORDER BY [clientName] ASC
I actually don't need the date column to show in my results, I just need to be able to filter the date to narrow the results.
Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.
SELECT DISTINCT [clientName], [callType], [softwareType] FROM [callData] WHERE (([clientName] LIKE '%' + @clientName + '%') AND ([softwareType] LIKE '%' + @softwareType + '%') AND ([callType] LIKE '%' + @callType + '%') AND ([date] >= Convert(datetime,@startDate)) AND ([date] <= Convert(datetime,@endDate))) GROUP BY [clientName], [callType], [softwareType] ORDER BY [clientName] ASC
I need to be able to filter the date range from the data, but I don't need it to show in the gridview.
If I remove the column, will I still beable to filter the data?
Excellent. Thanks again.. I had to get around the tree in front of me :)
Not the solution you were looking for?
IT issues often require a personalized solution. With Ask the Experts™, submit your questions to our certified professionals and receive unlimited, customized solutions that work for you.
Premium Content
You need an Expert Office subscription to comment.Start Free Trial