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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select in teradat

Status
Not open for further replies.

kartdb

Programmer
Jul 29, 2002
6
US
I have a query wich goes some thing like this...

select count(a.dept),count(a.emp) from ((select Distinct 1,2,3 from (select 1,2,3,4,5 from dept) as a) as b;

1,2,3,4,5 are columns...

When I run this query,it is giving me the error,table/view/procedure a does not exits...

I there any wrong in my query or Is there any other approach...

I would appreciate some one's help..


Thank you....
 

the problem has to do with u using a.dept and a.emp in your main query coz the spool table a is inside spool table b and u cannot reference the columns from the inner query, moreover there is no alias name called emp and dept in your sql... make sure u give alias name to the columns in the spool table b and use those columns in you outer query...

if u can be more specific may be i can help u more.... it is very vague....


Regards

Sridharan
 
This may give you a little easier query, you are forcing a Cartesean join because there is no join criteria for the two tables:

SELECT
COUNT(distinct a.dept), t2.emp

FROM sourcetab a

INNER JOIN

(Select COUNT (distinct sourcetab.emp)from sourcetab) t2(emp)

GROUP BY 2 ;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top