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
 General SQL Server Forums
 New to SQL Server Programming
 Fairly New to SQL, getting Error Msgs

Author  Topic 

stephenf
Starting Member

1 Post

Posted - 2010-04-30 : 16:14:53
And this thing is driving me batty! I am trying to create a temp table. It is giving me the error:

Msg 207, Level 16, State 1, Line 64
Invalid column name 'MIN'.

and

Msg 116, Level 16, State 1, Line 64
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.


This is my butchered, probably, code:

quote:
Insert into ##MyAwesomeTable

Select dbo.a.b,
dbo.a.c,
dbo.a.d,
dbo.a.e,
dbo.a.f

from dbo.a

where dbo.a.f = (Select MIN (dbo.a.e) from dbo.a where dbo.a.TransactionID = '126303')


then following, because I haven't figured out how to get looping going, so a lot of manual coding,:

quote:
Insert into ##MyAwesomeTable

Select dbo.a.b,
dbo.a.c,
dbo.a.d,
dbo.a.e,
dbo.a.f

from dbo.a

where dbo.a.f = (Select MIN,+1,(dbo.a.e) from dbo.a where dbo.a.TransactionID = '126303')



This continues at least 10 more times, with (Select MIN, +2,( or +3. I am getting the errors above.

Any help would be greatly appreciated.


Telvez Te Quiero, Pero Primero Es Lo Primero.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-30 : 16:46:30
Insert into ##MyAwesomeTable

Select a.b,a.c,a.d,a.e,a.f
from dbo.a
where a.f = (Select MIN(a.e) from dbo.a where a.TransactionID = '126303')

Then MIN(a.e) + 1 etc.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-01 : 00:53:58
this will return you only those rows which have a.f value equal to minimum a.e for the transaction with id 126303. is this your exact reqmnt?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -