470,632 Members | 2,176 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,632 developers. It's quick & easy.

Conditional select in a view

Greetings all,
I have three databases dmart, dmart_a and dmart_b. The first being a pointer database, has lookup table that one has to query to know which one of the two databases (dmart_a and dmart_b) is online. I want to create a view which can dynamically select the data from the database that is online . Following is the SQL which I was able to write however I am not able to precede any further b'cause of error Sub-query returns more than one row. All your suggestions are welcomed.

WHEN dbname = 'dmart_a'
THEN (select count(*) from dmart_a.upload.person_data)
ELSE (select count(*) from dmart_b.upload.person_data)
END --AS 'Database to point'
FROM dmart_db_pointer
Jul 24 '07 #1
0 835

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by Guy Hocking | last post: by
28 posts views Thread by Benjamin Niemann | last post: by
8 posts views Thread by Dimitri Furman | last post: by
5 posts views Thread by Andrew Chanter | last post: by
3 posts views Thread by Tom | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.