Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Probably a simple join for someone

Author  Topic 

Maccaman
Starting Member

16 Posts

Posted - 2010-01-30 : 00:30:52
Hi,
I have two tables I'm trying to join, but I don't know which join to use, and what to join them on.
My first table (called TempData) is a list of average temps per season:

Temperature Season
38 Summer
26 Fall
15 Winter
32 Spring


My Second Table (called SeasonSequence) consists of each season and a sequence number:

Season2 SequenceNo
Summer 1
Summer 2
Summer 3
Summer 4
Fall 4
Fall 1
Fall 2
Fall 3
Winter 3
Winter 4
Winter 1
Winter 2
Spring 2
Spring 3
Spring 4
Spring 1

Im trying to join these tables so that I obtain the following Table:
Temperature Season Season2 SequenceNo
38 Summer Summer 1
26 Fall Summer 2
15 Winter Summer 3
32 Spring Summer 4
38 Summer Fall 4
26 Fall Fall 1
15 Winter Fall 2
32 Spring Fall 3
38 Summer Winter 3
26 Fall Winter 4
15 Winter Winter 1
32 Spring Winter 2
38 Summer Spring 2
26 Fall Spring 3
15 Winter Spring 4
32 Spring Spring 1

I thought a union would have done this, but when I try I get an error: Error converting data type varchar to float. Im probably wrong about the union though.
Any help would be greatly appreciated.
Thanks



"I know the human being and fish can co-exist peacefully" - George W. Bush.
Obviously Mr Bush has never been fishing with me :)

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-01-30 : 00:38:05
how is the 1st table related to the 2nd table ?

how do you want to join these 2 tables ? Based on what condition ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2010-01-31 : 09:41:14
You mean joining based on Season.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-01-31 : 09:53:33
That looks senseless to me if every season has the same average temp .
Can you make more clear why you want to do this?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -