Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 how design query Rate Topic Display Mode Topic Options
Author
 Message
 Posted Monday, November 8, 2010 12:15 AM
 Forum Newbie Group: General Forum Members Last Login: Tuesday, November 30, 2010 11:23 PM Points: 3, Visits: 12
 hi all below i am showing my bus route table now how i can find out which route will come if i user want to go B to D stop (If user choose B to D stop then route no 1 will come)Id Route Stops Stopno1 1 A 12 1 B 23 1 C 34 1 D 45 1 E 56 2 A 57 2 B 48 2 C 39 2 D 210 2 E 1
Post #1017014
 Posted Monday, November 8, 2010 12:19 AM
 SSCertifiable Group: General Forum Members Last Login: Wednesday, September 23, 2015 3:34 PM Points: 5,467, Visits: 7,660
 Bunty, you left out too much of the question for us to even point you in the right direction, because if I read this right, you CAN go from B to D. If you're going to ask homework questions, at least do it properly, see the first link in my signature. - Craig FarrellNever stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake. For better assistance in answering your questions | Forum NetiquetteFor index/tuning help, follow these directions. |Tally TablesTwitter: @AnyWayDBA
Post #1017015
 Posted Monday, November 8, 2010 12:19 AM
 SSCommitted Group: General Forum Members Last Login: Thursday, December 1, 2016 12:53 PM Points: 1,935, Visits: 3,150
 post your query? ----------------------------------------------Msg 8134, Level 16, State 1, Line 1Divide by zero error encountered.
Post #1017016
 Posted Monday, November 8, 2010 12:31 AM
 Forum Newbie Group: General Forum Members Last Login: Tuesday, November 30, 2010 11:23 PM Points: 3, Visits: 12
 select distinct t1.routeno from Table_1 t1 innerjoin Table_1 t2 on t2.stop=t1.stop where (t1.stop='D' and t1.stopnot2.stopno ) problem in this query is its showing me route no 2 also select distinct t1.routeno from Table_1 t1 innerjoin Table_1 t2 on t2.stop=t1.stop where (t1.stop='A' and t1.stopnot2.stopno ) This Query running fine there is to route (route no 1 and route no 2 )Route no 1 Bus going (A stop to E Stop) andRoute no 2 Bus going (E stop to A Stop)If user want to go stop A to E or D to E then route no 1 will come. but i am not avail to find out how i design my query.
Post #1017019
 Posted Monday, November 8, 2010 9:29 PM
 Forum Newbie Group: General Forum Members Last Login: Tuesday, November 30, 2010 11:23 PM Points: 3, Visits: 12
 Got it Thanks every select distinct t1.*,T2.* from Table_1 t1 innerjoin Table_1 t2 on t1.routeno=t2.routeno where (t1.stop='A' ) and (t2.stop='E')and t2.stopno>t1.stopnoorder by t1.routenoselect distinct t1.*,T2.* from Table_1 t1 innerjoin Table_1 t2 on t1.routeno=t2.routeno where (t1.stop='D' ) and (t2.stop='E')and t2.stopno>t1.stopnoorder by t1.routeno
Post #1017584

 Permissions