Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subquery in SQL select statement

Status
Not open for further replies.

dolodolo

Technical User
May 27, 2003
86
0
0
US
I’m trying to run the following script and get an error (see below):

select
ach.hperson,
ach.sname,
ach.sacct,
ach.bportal,
ach.hroommate
FROM
(select hperson, count(hmy), brecur
from achdata
where brecur <> 0
group by hperson, brecur
having count(hmy) > 1) main
inner join achdata ach on ach.hperson = main.hperson

Server: Msg 8155, Level 16, State 2, Line 1
No column was specified for column 2 of 'main'.

Please help,
Thanks
 
You need to create a name for your count column.

For example: count(hmy) As hmy_count

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top