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.
| Author |
Topic |
|
Vaishu
Posting Yak Master
178 Posts |
|
|
hanbingl
Aged Yak Warrior
652 Posts |
Posted - 2008-10-28 : 14:07:58
|
| Define NunofHits. where is it stored at. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-29 : 00:09:54
|
make be thisSELECT URL,SearchTerms,CASE WHEN Seq=1 THEN ProductID ELSE NULL END AS ProductID,CASE WHEN Seq=1 THEN NumOFHits ELSE NULL END AS NumOFHitsFROM(SELECT URL,SearchTerms,ProductID,COUNT(*) OVER(PARTITION BY ProductID) AS NumOfHits,ROW_NUMBER() OVER(PARTITION BY ProductID ORDER BY SearchTerms) AS SeqFROM Table)tORDER BY NumOFHits DESC,ProductID ASC |
 |
|
|
Vaishu
Posting Yak Master
178 Posts |
Posted - 2008-10-29 : 05:54:24
|
HII am getting Incorrect syntax near second select command. Also NumOfHits is the counts of ProdutId.quote: Originally posted by visakh16 make be thisSELECT URL,SearchTerms,CASE WHEN Seq=1 THEN ProductID ELSE NULL END AS ProductID,CASE WHEN Seq=1 THEN NumOFHits ELSE NULL END AS NumOFHitsFROM vWTable(SELECT URL,SearchTerms,ProductID,COUNT(*) OVER(PARTITION BY ProductID) AS NumOfHits,ROW_NUMBER() OVER(PARTITION BY ProductID ORDER BY SearchTerms) AS SeqFROM vWTable)tORDER BY NumOFHits DESC,ProductID ASC
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-29 : 06:02:09
|
quote: Originally posted by Vaishu HII am getting Incorrect syntax near second select command. Also NumOfHits is the counts of ProdutId.quote: Originally posted by visakh16 make be thisSELECT URL,SearchTerms,CASE WHEN Seq=1 THEN ProductID ELSE NULL END AS ProductID,CASE WHEN Seq=1 THEN NumOFHits ELSE NULL END AS NumOFHitsFROM vWTable(SELECT URL,SearchTerms,ProductID,COUNT(*) OVER(PARTITION BY ProductID) AS NumOfHits,ROW_NUMBER() OVER(PARTITION BY ProductID ORDER BY SearchTerms) AS SeqFROM vWTable)tORDER BY NumOFHits DESC,ProductID ASC
this is not what i posted. remove the view name near FROM |
 |
|
|
Vaishu
Posting Yak Master
178 Posts |
Posted - 2008-10-29 : 06:04:46
|
HiFantastic. Thanks a lot SUPERMAN.quote: Originally posted by visakh16
quote: Originally posted by Vaishu HII am getting Incorrect syntax near second select command. Also NumOfHits is the counts of ProdutId.quote: Originally posted by visakh16 make be thisSELECT URL,SearchTerms,CASE WHEN Seq=1 THEN ProductID ELSE NULL END AS ProductID,CASE WHEN Seq=1 THEN NumOFHits ELSE NULL END AS NumOFHitsFROM vWTable(SELECT URL,SearchTerms,ProductID,COUNT(*) OVER(PARTITION BY ProductID) AS NumOfHits,ROW_NUMBER() OVER(PARTITION BY ProductID ORDER BY SearchTerms) AS SeqFROM vWTable)tORDER BY NumOFHits DESC,ProductID ASC
this is not what i posted. remove the view name near FROM
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-29 : 06:05:44
|
Cheers |
 |
|
|
|
|
|
|
|