File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes subquery in transact sql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "subquery in transact sql" Watch "subquery in transact sql" New topic

subquery in transact sql

Archanaa Panchal

Joined: Sep 22, 2004
Posts: 7
hi all,

ok..ere's what the problem is. i am using a subquery to select multiple rows in a table, take a specific field out of them, and sum them up, and return the result (which should be one float value) to a field in a temp table in a stored proc.

when i run the subquery by itself, using the same constraints and the same generic table, it does return only one value for each field. but when i try to put the query as a subquery and assign its result to the specific column in my temp table, i get an error saying
"cannot assign result to var since subquery returned more than one value"

its taken me 4 days to just get my basic code going - and i spent all of today staring at this without any luck. ive tried everything...nothing works!!

Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

show the query.

I guess the subquery isn't bound to the outer query correctly.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32793

Can you post your query?

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: subquery in transact sql
It's not a secret anymore!