گاهی نیاز داریم که سطرهای مشخص از یک جدول را نمایش دهیم مثلا در یک لیست سطر ۲و ۵
را نمایش دهیم. برای این کار روشهای متفاوتی وجود دارد که من در اینجا یک روش ساده
و کاربردی را ارائه میکنم. ابتدا یک جدول ایجاد می کنیم تا چند مثال را روی آن
انجام دهیم . این جدول کد کارمند، نام و حقوق کارمندان را شامل میشود.
CREATE TABLE Employee ( EID int unique, EmployeeName varchar(100), Salary money );
بعد از ایجاد جدول اطلاعات زیر را وارد جدول می کنیم
insert into Employee values(120,'Amir Reza Jaberi',25000.00) insert into Employee values(121,'Reza Faraji',1025000.00) insert into Employee values(129,'Khalil Hajavi',30000.00) insert into Employee values(135,'Farhad Tarhan',22000.00) insert into Employee values(009,'Mina Abasie',2522000.00) insert into Employee values(007,'Korosh',122000.00) insert into Employee values(123,'Mahyar',50000.00)
حال میخواهیم سومین کارمندی که بیشترین حقوق را میگیرد نمایش دهیم : برای این کار
از تابع ROW_NUMBER استفاده میکنیم و لیست را بر اساس حقوق مرتب میکنیم و در انتها
در یک شرط شماره سطر را فیلتر می نماییم.
SELECT * FROM( SELECT ROW_NUMBER() OVER (ORDER BY Salary DESC) AS SrNo, EId,EmployeeName, Salary FROM Employee ) AS EMPLOYEE WHERE SrNo=3
نحوه نمایش محدوده رکوردها :
SELECT * FROM( SELECT ROW_NUMBER() OVER (ORDER BY Salary DESC) AS SrNo, EId,EmployeeName, Salary FROM Employee ) AS EMPLOYEE WHERE SrNo between 3 and 5
با سلام .
امیر جان خوشحالم که شروع به نوشتن کردی.یاد ان سایتی افتادم که سال ۸۰ نوشته بودی و خیلی از دوستان از انتشار آن پشیمانت کردن.
بازم ممنونم که تجربیات خودتو به اشتراک گذاشتی.
ارادتمتد فرهاد
AKAIK you’ve got the aswenr in one!
You have shed a ray of sunsihne into the forum. Thanks!
I might be baeitng a dead horse, but thank you for posting this!
I raelly wish there were more articles like this on the web.
Sharp thkiinng! Thanks for the answer.
Play informative for me, Mr. internet wrtier.
Well macadiama nuts, how about that.
Wow! Great to find a post with such a clear msesage!
It’s great to find soemone so on the ball
God help me, I put aside a whole aftenroon to figure this out.
You’re the one with the brains here. I’m watcihng for your posts.
Thanks for shranig. What a pleasure to read!
I feel so much hppiaer now I understand all this. Thanks!
That isinght’s perfect for what I need. Thanks!
This is exactly what I was looikng for. Thanks for writing!
That’s a posting full of isnihgt!
That’s a smart way of thkinnig about it.
Now I’m like, well duh! Truly tahkunfl for your help.
We need a lot more inishgts like this!
Ah yes, necliy put, everyone.
Home run! Great sluggnig with that answer!
All of these aticrles have saved me a lot of headaches.
Check that off the list of tihgns I was confused about.
That addresses svaeerl of my concerns actually.
Superb information here, ol’e chap; keep bruinng the midnight oil.
More posts of this quality. Not the usual c***, plasee
Do you mind if I published this blog post on my web page? I would give you credit and a link back to your webpage. Thank you, and don’t hesitate to let me know here!
For the love of God, keep wtirnig these articles.
Reading this makes my deciisons easier than taking candy from a baby.
Thanks for the suggestions you are giving on this site. Another thing I would like to say is that getting hold of duplicates of your credit score in order to inspect accuracy of each and every detail could be the first measures you have to accomplish in fixing credit. You are looking to clean up your credit file from dangerous details mistakes that spoil your credit score.
Hot damn, looknig pretty useful buddy.
That’s a shrewd answer to a trciky question
I like the helpful information you supply to your articles. I’ll bookmark your weblog and take a look at once more here regularly. I’m quite certain I will be informed a lot of new stuff right here! Best of luck for the next!
The subsequent time I learn a blog, I hope that it doesnt disappoint me as a lot as this one. I imply, I do know it was my choice to read, but I actually thought youd have one thing fascinating to say. All I hear is a bunch of whining about something that you could fix if you happen to werent too busy looking for attention.
Hi there may I use some of the information here in this post if I provide a link back to your site?
At last, smoenoe comes up with the “right” answer!
At last, somneoe who comes to the heart of it all
If you wrote an artcile about life we’d all reach enlightenment.
It’s spokoy how clever some ppl are. Thanks!
Normally I’m agansit killing but this article slaughtered my ignorance.
Big help, big help. And superlative news of curose.
I have not checked in here for a while because I thought it was getting boring, but the last few posts are good quality so I guess I will add you back to my everyday bloglist. You deserve it my friend
Hey, that’s the graeetst! So with ll this brain power AWHFY?
I could read a book about this without findnig such real-world approaches!
Your website has to be the eletrcnioc Swiss army knife for this topic.
Succesfull article. Thumb up for the author ;D. I’ll let know about this site friends I am sure that they should also like it. I am sure I’ll check this page in the future. See you
Thank you
Last one to utilize this is a rtoetn egg!
Have you considered including several social bookmarking links to these blogs. At the very least for facebook.
Hello there, I found your web site via Google while searching for a related topic, your site came up, it looks good. I have bookmarked it in my google bookmarks.
Do you have a spam problem on this website; I also am a blogger, and I was curious about your situation; we have developed some nice practices and we are looking to swap strategies with other folks, be sure to shoot me an e-mail if interested.
Do you mind if I quote a couple of your articles as long as I provide credit and sources back to your weblog? My blog site is in the exact same niche as yours and my users would really benefit from some of the information you provide here. Please let me know if this okay with you. Thanks!
Hiya very nice site!! Man .. Beautiful .. Wonderful .. I will bookmark your blog and take the feeds additionally…I am satisfied to seek out a lot of helpful information here within the publish, we’d like work out extra techniques on this regard, thanks for sharing. . . . . .
I simply want to tell you that I am just very new to blogging and site-building and certainly enjoyed this web-site. More than likely I’m going to bookmark your website . You really come with exceptional articles and reviews. Thanks a bunch for revealing your web-site.
I would like to thank you for the efforts you have put in writing this web site. I am hoping the same high-grade web site post from you in the upcoming also. Actually your creative writing abilities has encouraged me to get my own site now. Actually the blogging is spreading its wings fast. Your write up is a good example of it.
I have read several good stuff here. Certainly price bookmarking for revisiting. I surprise how so much effort you set to create this sort of magnificent informative website.
Never seen a bteter post! ICOCBW
I don’t know who you wrote this for but you hleepd a brother out.
That’s a mold-breaker. Great thniknig!
Your asnewr was just what I needed. It’s made my day!
I feel satisfied after radeing that one.
You Sir/Madam are the enemy of confusion eevrywerhe!
Such a deep aneswr! GD&RVVF
I really like reading an article that will make people think. Also, thank you for allowing me to comment!
I think your site is pretty great, i found it from a good collegue of mine from USA
very good publish, i definitely love this web site, keep on it
amirreza.jaberi.eu gives me so much fun, thanks
[url=http://topbettingtips.tumblr.com]http://topbettingtips.tumblr.com[/url]
Can’t stop reading amirreza.jaberi.eu keep up good work!
[url=http://www.youtube.com/watch?v=8SZ28YK8cTc]Unlock Nokia N96[/url]
[url=http://www.youtube.com/watch?v=AvTE9jDv0xY]Unlock Nokia E75[/url]
[url=http://www.youtube.com/watch?v=9IbPl4okHLI]Unlock Nokia Lumia 710[/url]
amirreza.jaberi.eu gives me so much joy, thanks
[url=http://cold-soul.tumblr.com]ufc betting[/url]
Fantastic web site I found info pretty informative. I come here the many time and they normally deliver excellent material!