RSS Forums RSS
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 3480 | Replies: 7 | Thread Tools  Display Modes
Reply
Join Date: Jul 2005
Posts: 41
Reputation: ohgosh is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ohgosh's Avatar
ohgosh ohgosh is offline Offline
Light Poster

is order by and group by the same?

  #1  
Sep 15th, 2005
Hi there,

wanna ask if the sql syntax order by and group by the same?
eg: i have a dropdownlist and the values displayed should be in ascending order. hence is there any difference if i use these 2 sql statements below.

sql1 = "select distinct * from t_staff group by staff"
sql2 = "select distinct * from t_staff order by staff"

i've tested it out and it works well. was curious to know if there is any explaination/meaning behind the scene.

Though i know it may be peanut to you guys..but Thanks Alot!
cheers,
ohgosh
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2005
Posts: 41
Reputation: ohgosh is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ohgosh's Avatar
ohgosh ohgosh is offline Offline
Light Poster

Re: is order by and group by the same?

  #2  
Sep 15th, 2005
oops :x sorry i think i post this thread to the wrong forum..

see ya guys in the forum under databases. hope to hear from you soon.
cheers,
ohgosh
Reply With Quote  
Join Date: Sep 2005
Posts: 9
Reputation: amitlokare is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
amitlokare amitlokare is offline Offline
Newbie Poster

Re: is order by and group by the same?

  #3  
Sep 15th, 2005
Hi,
Ya there is difference in order by and group by
When u fire group by query its aggregate similar entries and show u single entriy for tht
but in order by u order list in alphabeticaly order
Reply With Quote  
Join Date: Jul 2005
Posts: 41
Reputation: ohgosh is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ohgosh's Avatar
ohgosh ohgosh is offline Offline
Light Poster

Re: is order by and group by the same?

  #4  
Sep 15th, 2005
Originally Posted by amitlokare
Hi,
Ya there is difference in order by and group by
When u fire group by query its aggregate similar entries and show u single entriy for tht
but in order by u order list in alphabeticaly order

wad u mean by aggregrate similar entries? do u mean pick up oli distinct records? do it mean different if i remove distinct from select statement?

but i can still display my dropdownlist value in alphabeticaly order if i use group by..

is there anywhere to order the list in alphabeticaly order besides using order by?
cheers,
ohgosh
Reply With Quote  
Join Date: Sep 2005
Posts: 9
Reputation: amitlokare is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
amitlokare amitlokare is offline Offline
Newbie Poster

Re: is order by and group by the same?

  #5  
Sep 15th, 2005
Why u not using orderby its not have any distadvantage
Reply With Quote  
Join Date: Jul 2005
Posts: 41
Reputation: ohgosh is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ohgosh's Avatar
ohgosh ohgosh is offline Offline
Light Poster

Re: is order by and group by the same?

  #6  
Sep 15th, 2005
huh wad do u mean? i try using order by, but error occured on the page. i dont understand wad happen so i had to use another method to resolve.
cheers,
ohgosh
Reply With Quote  
Join Date: Mar 2005
Location: LTT, South Africa
Posts: 125
Reputation: william_stam is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
william_stam's Avatar
william_stam william_stam is offline Offline
Junior Poster

Re: is order by and group by the same?

  #7  
Sep 19th, 2005
paste your sql statement
Reply With Quote  
Join Date: Jul 2005
Posts: 41
Reputation: ohgosh is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ohgosh's Avatar
ohgosh ohgosh is offline Offline
Light Poster

Re: is order by and group by the same?

  #8  
Sep 19th, 2005
didn't i paste my sql statemt during my very 1st post?

sql1 = "select distinct * from t_staff group by staff"
sql2 = "select distinct * from t_staff order by staff"

btw ive used group by and it works well so i stil remain using group by.. :surprised
cheers,
ohgosh
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the ASP Forum
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 5:48 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC