|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
LIMIT Statement
Greetings from germany,
I need to limit my results. I worked with a mySQL database. There the syntax was like: Select table.* From table LIMIT 0,3 That means I want to recieve 3 results max. But it doesnt work with the ms sql Server! Can somebody help me please. Thank you, z-d-m |
|
#2
|
||||
|
||||
|
select top 3 * from yourtable
this really only makes sense (and in the mysql version as well) if you have an ORDER BY clause |
|
#3
|
|||
|
|||
|
how about between two numbers
How about between rows 5 and 15? In MySQL, I could do like
Select * from table limit 5,15; I did not find a similar implementation in MSSql. Does it not exist? Thanks, rks Quote:
|
|
#4
|
||||
|
||||
|
yeah, it exists, but it's ugly
Code:
select *
from (
select top 10 foo, bar
from (
select top 15 foo, bar
from thetable
order
by bar desc
) as dt1
order
by bar asc
) as dt2
order
by bar desc
|
|
#5
|
|||
|
|||
|
Oh ! vow!! I am surprised.. How does MySql has such flexibility and MS SQL does not! Anyway, I know now how to do it. Thank you very much.
Quote:
|
|
#6
|
||||
|
||||
|
I would suggest you to take a look at this article about paging records with stored procedures.
__________________
My blog about OpenSource Databases PDF tutorials about OSS databases, DBMonster ... Please contribute to Open Source Development, fill bug reports!!! Developer Shed eSupport Commented my.ini/my.cnf (PLEASE ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > LIMIT Statement |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|