| Author |
Topic |
|
sqlneve
Starting Member
16 Posts |
Posted - 2008-12-10 : 09:38:25
|
| i want to do an inner join (i think) but the table i want to join to is itself. can anyone point me in the right direction on this? i'm such a newb!In my table I want to know where address' are the same, id's are the same but longitude is different. so all i have is the end part of the querySelect*From txallinner join txallon id = idand address1 = address1and city = cityand longi <> longiand county = 'williamson'can anyone help me outthanks! |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-12-10 : 09:45:57
|
[code]SELECT address1 city, COUNT(*)FROM txAllWHERE county = 'Willimason'GROUP BY address1 cityHAVING MIN(longi) < MAX(longi) OR MIN(lati) < MAX(lati)ORDER BY city, address1[/code] E 12°55'05.63"N 56°04'39.26" |
 |
|
|
sqlneve
Starting Member
16 Posts |
Posted - 2008-12-10 : 09:54:00
|
| The Count (*) is throwing an incorrect syntax error???? |
 |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2008-12-10 : 09:54:56
|
| put a comma after address1 in select |
 |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2008-12-10 : 09:55:59
|
| and one after address1 again in group by clause. Also, do you have lati column with you ? |
 |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2008-12-10 : 09:57:24
|
| [code]select id,address1,city,count(distinct longitude)fromtxall group by id,address1,cityhaving count(distinct longitude)>1[/code] |
 |
|
|
sqlneve
Starting Member
16 Posts |
Posted - 2008-12-10 : 09:59:07
|
| Yes, I do have a lat column as well but not a lati. (I caught that as well) I added the comma and double checked all other areas where i thought there might need to be one but the error keeps coming up. Thank you all so much for working with me on this! I can't tell you how much I have been learning in here. |
 |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2008-12-10 : 10:04:34
|
whats the error when you run this ?select id,address1,city,count(distinct longitude),count(distinct lat) from txall group by id,address1,cityhaving count(distinct longitude)>1 or count(distinct lat)>1 |
 |
|
|
sqlneve
Starting Member
16 Posts |
Posted - 2008-12-10 : 10:22:20
|
No error! Thank you so much |
 |
|
|
|