我有这张桌子:
table session(
ID number,
SessionID VarChar,
Date,
Filter
)
此表包含搜索信息,如下所示:
ID SessionID Date filter
4 peqq421gaspts3nuulq5mwcq 24/05/2012 13:48 meagPixel=5
6 peqq421gaspts3nuulq5mwcq 24/05/2012 13:48 brand=Canon
7 peqq421gaspts3nuulq5mwcq 24/05/2012 13:48 brand=Canon&meagPixel=12.1
8 peqq421gaspts3nuulq5mwcq 24/05/2012 13:48 brand=Canon
10 peqq421gaspts3nuulq5mwcq 24/05/2012 13:48 brand=Nikon
12 peqq421gaspts3nuulq5mwcq 24/05/2012 13:48 meagPixel=12.1
13 peqq421gaspts3nuulq5mwcq 24/05/2012 13:48 meagPixel=12.1&opticalZoom=True
14 peqq421gaspts3nuulq5mwcq 24/05/2012 13:49 meagPixel=12.1&opticalZoom=True&brand=Panasonic
16 peqq421gaspts3nuulq5mwcq 24/05/2012 13:49 price=500.00
18 peqq421gaspts3nuulq5mwcq 24/05/2012 13:49 price=499.00
19 peqq421gaspts3nuulq5mwcq 24/05/2012 13:49 price=499.00&brand=Olympus
21 peqq421gaspts3nuulq5mwcq 24/05/2012 13:49 zoomRange=2000
22 peqq421gaspts3nuulq5mwcq 24/05/2012 13:49 zoomRange=2000&brand=Leica
23 peqq421gaspts3nuulq5mwcq 24/05/2012 13:49 zoomRange=2000&brand=Leica&price=1995.00
24 peqq421gaspts3nuulq5mwcq 24/05/2012 13:49 zoomRange=2000&brand=Leica&price=1995.00&opticalZoom=True
25 peqq421gaspts3nuulq5mwcq 24/05/2012 13:49 zoomRange=2000&brand=Leica&price=1995.00&opticalZoom=True&meagPixel=16.2
26 peqq421gaspts3nuulq5mwcq 24/05/2012 13:50 zoomRange=2000&brand=Leica&price=1995.00&opticalZoom=True&meagPixel=16.2&weight=345
27 peqq421gaspts3nuulq5mwcq 24/05/2012 13:58 zoomRange=2000&brand=Leica&price=1995.00&opticalZoom=True&meagPixel=16.2
41 poiq41111spts00000q5aaaa 27/05/2012 13:48 meagPixel=5
我想获得独特的搜索。独特的搜索是:
- 用户(会话)的最长搜索(过滤器)
- 如果第一个过滤器发生变化 - 它需要被视为新搜索(过滤器)
由于 ASP.NET 不保证 SessionID 是唯一的 (SessionID,Date) 是唯一的。
我没走多远:
SELECT MAX(Filter)
FROM Session
GROUP BY SessionID
顺便说一句,我给出的示例表数据的结果应该返回:
ID SessionID Date filter
4 peqq421gaspts3nuulq5mwcq 24/05/2012 13:48 meagPixel=5
7 peqq421gaspts3nuulq5mwcq 24/05/2012 13:48 brand=Canon&meagPixel=12.1
10 peqq421gaspts3nuulq5mwcq 24/05/2012 13:48 brand=Nikon
14 peqq421gaspts3nuulq5mwcq 24/05/2012 13:49 meagPixel=12.1&opticalZoom=True&brand=Panasonic
16 peqq421gaspts3nuulq5mwcq 24/05/2012 13:49 price=500.00
19 peqq421gaspts3nuulq5mwcq 24/05/2012 13:49 price=499.00&brand=Olympus
26 peqq421gaspts3nuulq5mwcq 24/05/2012 13:50 zoomRange=2000&brand=Leica&price=1995.00&opticalZoom=True&meagPixel=16.2&weight=345
41 poiq41111spts00000q5aaaa 27/05/2012 13:48 meagPixel=5
感谢您的任何帮助和指导。