473,385 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

SQL puzzle

I have three queries.

If the counts returned from the first and second queries are equal
then the third query is executed.

Is it possible to get this information in a single query without
writing a procedure?

Thanks.
SELECT COUNT(*) FROM NAV_DIV_GROUP NDG INNER JOIN EMP_GROUP EG ON
NDG.GROUP_ID=EG.GROUP_ID
WHERE EG.EMP_ID=? AND NDG.NAV_DIV_ID=?

SELECT GROUP_COUNT FROM NAV_DIV WHERE NAV_DIV_ID=?

SELECT NAV_DIV_ID, NAV_PAGE_ID, COLUMN_NO, POSITION_NO, GROUP_COUNT,
TYPE, BOBLET_NAME, ADMIN_NAME, PATH,
BLURB FROM NAV_DIV WHERE NAV_DIV_ID=?

Apr 9 '07 #1
3 1692
gi*******************@yahoo.com wrote:
I have three queries.

If the counts returned from the first and second queries are equal
then the third query is executed.

Is it possible to get this information in a single query without
writing a procedure?

Thanks.
SELECT COUNT(*) FROM NAV_DIV_GROUP NDG INNER JOIN EMP_GROUP EG ON
NDG.GROUP_ID=EG.GROUP_ID
WHERE EG.EMP_ID=? AND NDG.NAV_DIV_ID=?

SELECT GROUP_COUNT FROM NAV_DIV WHERE NAV_DIV_ID=?

SELECT NAV_DIV_ID, NAV_PAGE_ID, COLUMN_NO, POSITION_NO, GROUP_COUNT,
TYPE, BOBLET_NAME, ADMIN_NAME, PATH,
BLURB FROM NAV_DIV WHERE NAV_DIV_ID=?
I suspect that this is not what you are looking for, but just in case:

SELECT NAV_DIV_ID, NAV_PAGE_ID, COLUMN_NO, POSITION_NO, GROUP_COUNT,
TYPE, BOBLET_NAME, ADMIN_NAME, PATH,BLURB
FROM NAV_DIV
WHERE NAV_DIV_ID=?
AND (SELECT COUNT(*)
FROM NAV_DIV_GROUP NDG INNER JOIN EMP_GROUP EG
ON NDG.GROUP_ID=EG.GROUP_ID
WHERE EG.EMP_ID=? AND NDG.NAV_DIV_ID=?)
= ( SELECT GROUP_COUNT FROM NAV_DIV WHERE NAV_DIV_ID=? )

Apr 10 '07 #2
Untested:

SELECT nav_div_id, nav_page_id, column_no, position_no, group_cnt,
type, boblet_name, admin_name, path, blurb
FROM Nav_Div AS D1
WHERE nav_div_id = ?
AND (SELECT COUNT(*)
FROM nav_div_group AS NDG, emp_group AS EG
WHERE NDG.group_id = EG.group_id
AND EG.emp_id = ?
AND NDG.nav_div_id = D1.nav_div_id)
= (SELECT MAX(group_cnt) -- Max to keep it scalar
FROM Nav_Div
WHERE nav_div_id = nav_div_id);

"type" is too vague to be a data element -- what kind of type? Trees?
Shoes? Animals? Can you explain the logical difference differences
between "nav_page_id" and a mere "nav_page" or "nav_page_nbr"? I made
some guesses about what each ? should be.

Apr 10 '07 #3
Thanks Lennart. This worked perfectly.
Also, thanks CELKO.
Apr 19 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Developwebsites | last post by:
Hi all, I've made a sliding puzzle game in shockwave which works just fine, except I dont know how to have it solve itself. the URL is: http://members.aol.com/rglukov/games/selfsolve.htm ...
42
by: Frank Buss | last post by:
I've setup a challenge, mainly for C++, Java and Lisp, but every other language is welcome: http://www.frank-buss.de/challenge/index.html There is nothing to win, but I hope there will be some...
1
by: xavier vazquez | last post by:
I have a problem with a program that does not working properly...when the program run is suppose to generate a cross word puzzle , when the outcome show the letter of the words overlap one intop of...
0
by: xavier vazquez | last post by:
have a problem with a program that does not working properly...when the program run is suppose to generate a cross word puzzle , when the outcome show the letter of the words overlap one intop of the...
5
by: ashish0799 | last post by:
HI I M ASHISH I WANT ALGORYTHMUS OF THIS PROBLEM Jigsaw puzzles. You would have solved many in your childhood and many people still like it in their old ages also. Now what you have got to do...
3
by: oncue01 | last post by:
Word Puzzle Task You are going to search M words in an N × N puzzle. The words may have been placed in one of the four directions as from (i) left to right (E), (ii) right to left (W), (iii) up...
6
by: Phoe6 | last post by:
Hi All, I would like to request a code and design review of one of my program. n-puzzle.py http://sarovar.org/snippet/detail.php?type=snippet&id=83 Its a N-puzzle problem solver ( Wikipedia page...
2
by: Gio | last post by:
I'm getting K&R (it's on the way), should I also get the Answer Book? And while I'm there, should I get the Puzzle Book? Or should I save the Puzzle Book for when I'm more advanced? - Gio ...
4
by: honey777 | last post by:
Problem: 15 Puzzle This is a common puzzle with a 4x4 playing space with 15 tiles, numbered 1 through 15. One "spot" is always left blank. Here is an example of the puzzle: The goal is to...
5
by: dmf1207 | last post by:
Hi All! I'm new to javascript and need a little help with a simple puzzle im trying to design. I have a 600x100 pixel picture that I have sliced into 6 100x100 rectangles making a table of of 6...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.