×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

help in update select statement.

help in update select statement.

help in update select statement.

(OP)
I am running this query and basically I want to insert the row count values from diff_x and diff_y into tl_compare table. this query bombs on me.

UPDATE bi_stg_1.TL_COMPARE
from diff_x x, diff_y y
SET
count1 = ( select count(*) from x),
count2 = ( select count(*) from y)
WHERE DATABASE_NAME='stg' AND TABLE_NAME='delta' AND RUN_DATE=date AND INSTANCE1=8 AND INSTANCE2=7;

i get a Failure 3706 Syntax error: expected something between '(' and the 'select' keyword.

any alternatives or pointers to a solution?

RE: help in update select statement.

Try this :

CODE

UPDATE  bi_stg_1.tl_compare
FROM    (   SELECT  COUNT(*) AS cnt
            FROM    diff_x
        )   AS x
    ,   (   SELECT  COUNT(*) AS cnt
            FROM    diff_y
        )   AS  y
SET     count1 = x.cnt
    ,   count2 = y.cnt
WHERE   database_name = 'stg'
    AND table_name  = 'delta'
    AND run_date    = CURRENT_DATE
    AND instance1   = 8
    AND instance2   = 7
;

RE: help in update select statement.

(OP)
yes, this worked for me.
thanks

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close