Click here to Skip to main content
15,893,663 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I'm using sql 2005,having a table compraises of source,destination,via and date as columns. Now i want to retrieve the distinct values of destination and via by giving source. I am using the following query now(2 queries)..

SQL
select distinct DESTINATION from BUS AVAILABILITY WHERE SOURCE =@SOURCE
select distinct VIA from BUS AVAILABILITY WHERE SOURCE =@SOURCE


It is possible for me to join as an single query or it should be like this.
since am an beginner,I don't know how to use the distinction here.
Posted
Updated 11-Feb-12 1:44am
v2

SQL
SELECT Distinct DESTINATION,VIA from  BUS AVAILABILITY WHERE SOURCE =@SOURCE



Hope this helps if yes then accept and vote the answer otherwise revert back with your answer
--Rahul D.
 
Share this answer
 
Comments
Gopinath1005 11-Feb-12 5:37am    
thank yufor yur ans....but it not working boss....
RDBurmon 11-Feb-12 5:46am    
Why ? any error ?
Gopinath1005 11-Feb-12 6:05am    
no error..but i'm having the repeated values....
RDBurmon 11-Feb-12 6:10am    
Could you please share table stucture of [Bus Availability] and data in table

below is my skype id so that we can have voice conversation to understand better

rahul.dhoble
select distinct (DESTINATION) from BUS AVAILABILITY WHERE SOURCE =@SOURCE



for more to know about SQL queries visit the website "WWW.W3Scgools.com"

hope this may help you
 
Share this answer
 
Hi all..


finally i got an answer by using union function here...
thanks for your help...........
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900