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 |
|
ldbl
Starting Member
3 Posts |
Posted - 2005-06-22 : 08:59:17
|
| can anybody help me how to make query that can replace TOP command of MS SQL server . |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-06-22 : 09:03:03
|
| Look for RowCount in Books On LineMadhivananFailing to plan is Planning to fail |
 |
|
|
ldbl
Starting Member
3 Posts |
Posted - 2005-06-22 : 09:47:44
|
| it's not very importand to me to set numbers of rows to output it's enought only to get 1 row with most repeated record in the databasei'm stick here to get maximum with all data select * from (select #1057;#1090;#1086;#1082;#1072;#1048;#1044;,max(cnt)as maximum,DIN from (select n.#1057;#1090;#1086;#1082;#1072;#1048;#1044;,s.DIN,count(*) as cnt from #1090;#1073;#1053;#1072;#1083;#1080;#1095;#1085;#1086;#1089;#1090; as n JOIN #1090;#1073;#1057;#1090;#1086;#1082;#1080; as s ON n.#1057;#1090;#1086;#1082;#1072;#1048;#1044; = s.#1057;#1090;#1086;#1082;#1072;#1048;#1044; GROUP BY n.#1057;#1090;#1086;#1082;#1072;#1048;#1044;,s.DIN) as s GROUP BY cnt,#1057;#1090;#1086;#1082;#1072;#1048;#1044;,DIN) as bORDER BY maximum DESC |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-06-22 : 10:15:45
|
| What do you want to get from that?If you want to get most repeated value, you need to use CountSee BOL for more infoMadhivananFailing to plan is Planning to fail |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2005-06-23 : 04:49:26
|
| you're in the right direction using group byinclude the having clause: having count(*)>1 before the order byam not sure of your query, got confused with the #s and ;HTH though--------------------keeping it simple... |
 |
|
|
ldbl
Starting Member
3 Posts |
Posted - 2005-06-23 : 08:24:36
|
| here is from here i want to get max count.select * from (select count(*) as cnt ,s.din from Store as t1JOIN Stock as t2 ON t2.StockID = t1.StockIDGROUP BY s.din ) as t3ORDER BY t3.cnt DESC |
 |
|
|
|
|
|