بدست آوردن آخرین رکورد

matin.mt

New Member
سلام
من یه دستورselect نوشتم که مجموعه ای ازرکوردهارابازیابی می کنه
[ltr]
کد:
[FONT=Arial][FONT=Arial][COLOR=blue][FONT=Courier New][COLOR=blue][FONT=Courier New]select[/FONT][/COLOR][FONT=Courier New][COLOR=#000000] Kala[/COLOR][COLOR=gray],[/COLOR][COLOR=fuchsia]sum[/COLOR][COLOR=gray]([/COLOR][COLOR=#000000]Sell[/COLOR][COLOR=gray].[/COLOR][COLOR=#000000]Tedad[/COLOR][COLOR=gray])[/COLOR][COLOR=blue]AS[/COLOR][COLOR=#000000] C[/COLOR][/FONT]
[FONT=Courier New][COLOR=blue]from[/COLOR][COLOR=#000000] Sell[/COLOR][/FONT]
[FONT=Courier New][COLOR=blue]where[/COLOR][COLOR=#000000] UserID[/COLOR][COLOR=gray]=[/COLOR][COLOR=red]'a1'[/COLOR][/FONT]
[FONT=Courier New][COLOR=blue]group[/COLOR][COLOR=blue]by[/COLOR][COLOR=#000000] Kala[/COLOR][/FONT]
[FONT=Courier New][COLOR=blue]having[/COLOR][COLOR=fuchsia]sum[/COLOR][COLOR=gray]([/COLOR][COLOR=#000000]Sell[/COLOR][COLOR=gray].[/COLOR][COLOR=#000000]Tedad[/COLOR][COLOR=gray])>[/COLOR][COLOR=#000000]6[/COLOR][/FONT]
[/FONT][/COLOR]
[/FONT][/FONT]
[/ltr]

می خوام ازبین این رکوردها، رکوردآخرراانتخاب کنم.


می شه لطفاکمکم کنید؟

 
آخرین ویرایش:

MDP

Well-Known Member
این روشیه که من وقتی به استادم گفتم زمان دانشجویی بهم گفت تو مخت اخره بپیچونه :

کد:
[FONT=Arial][FONT=Arial][COLOR=blue][FONT=Courier New][COLOR=blue][FONT=Courier New]select Top 1[/FONT][/COLOR][FONT=Courier New][COLOR=#000000] Kala[/COLOR][COLOR=gray],[/COLOR][COLOR=fuchsia]sum[/COLOR][COLOR=gray]([/COLOR][COLOR=#000000]Sell[/COLOR][COLOR=gray].[/COLOR][COLOR=#000000]Tedad[/COLOR][COLOR=gray])[/COLOR][COLOR=blue]AS[/COLOR][COLOR=#000000] C[/COLOR][/FONT]
[FONT=Courier New][COLOR=blue]from[/COLOR][COLOR=#000000] Sell[/COLOR][/FONT]
[FONT=Courier New][COLOR=blue]where[/COLOR][COLOR=#000000] UserID[/COLOR][COLOR=gray]=[/COLOR][COLOR=red]'a1'[/COLOR][/FONT]
[FONT=Courier New][COLOR=blue]group[/COLOR][COLOR=blue]by[/COLOR][COLOR=#000000] Kala[/COLOR][/FONT]
[FONT=Courier New][COLOR=blue]having[/COLOR][COLOR=fuchsia]sum[/COLOR][COLOR=gray]([/COLOR][COLOR=#000000]Sell[/COLOR][COLOR=gray].[/COLOR][COLOR=#000000]Tedad[/COLOR][COLOR=gray])>[/COLOR][COLOR=#000000]6  order by Kala DESC
[/COLOR][/FONT][/FONT][/COLOR]
[/FONT][/FONT]

روش درست استفاده از Cursor هاست که خیلی سنگینه.
 

جدیدترین ارسال ها

بالا