assign a value to variable

I have to assign a result of a query to a vairable like this

how can i do this

Query = select count(*) from table
x=`db2 ${Query}| sed -n '4p'`

but this doesn't work, is there any other way to assign the result without redirecting the result to temp file. .

Thanks
Mark.

What shell are you using?

i am using ksh

I'm no db2 expert, but try this:

#!/bin/ksh

Query='select count(*) from table'
x=$(db2 "${Query}"| sed -n '4p')