Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to display the null values

Status
Not open for further replies.

shaleen7

MIS
Jun 23, 2002
188
US
Scenerio:
When we enter an application, the date that the app is entered is automatically assigned to the app. I'm trying to display all employees name regardless of whether they submitted an application for the month of March.

Desired Results for March
Hunt 5
Jaso 10
Kimb 13
Robb


Current Results for March
Hunt 5
Jaso 10
Kimb 13

Here is my SQL:
SELECT TABLENAMES "NAME", COUNT(TABLEAPPNO) "APP NO"

FROM TABLENAMES, TABLEAPPNO

WHERE TABLENAMES.IDEING=TABLEAPPNO.IDERES(+) AND

(VRPT_TABPRO.DATOUV BETWEEN TO_DATE('20040301','YYYYMMDD') AND TO_DATE('20040331','YYYYMMDD')

Any suggestions?
Thanks

 
Hi Shaleen,

Is the query is working without group by function? If not add the goup by clause in the query.

Regards
Krishna Reddy
mckreddy@visualsoft-tech.com
 
The group by is there. I neglected to copy it over.
 
Your sql query seems to be correct if the group by clause is present. Test the following three cases to identify the problem.

1. Modify the Where condition as follows and check either the desired records are coming.

WHERE TABLENAMES.IDEING(+)=TABLEAPPNO.IDERES

2. Modify the select statement as follows and check either the desired records are coming.

SELECT TABLENAMES "NAME", nvl(COUNT(TABLEAPPNO),0) "APP NO"

3. Remove the date checking condition in the where clause and check it.

Please note that in all the three cases the remaining sql statement is same, only modify the specific conditions and test it.

Regards
Krishna Reddy
mckreddy@visualsoft-tech.com
 
Thanks for the advice. I applied your suggestions to my query.

By using the query below I was able display all employees name regardless of whether they submitted an application.

SELECT TABLENAMES "NAME", NVL(COUNT(TABLEAPPNO),0) "APP NO"
FROM TABLENAMES, TABLEAPPNO
WHERE TABLENAMES.IDEING=TABLEAPPNO.IDERES(+)

however I have to place this date range on the query

AND (VRPT_TABPRO.DATOUV BETWEEN TO_DATE('20040301','YYYYMMDD') AND TO_DATE('20040331','YYYYMMDD')

Whenever I add the date range my query goes back to displaying the names of the employees who have submitted apps in March. I want to display all employee names regardless of whether they submitted an application for the month of March.

Any more suggestions? Many thanks....







 
When you need outer join, all conditions should be "outered":
Code:
...AND (VRPT_TABPRO.DATOUV(+) BETWEEN TO_DATE('20040301','YYYYMMDD') AND TO_DATE('20040331','YYYYMMDD')


Regards, Dima
 
If the above solution given by Dima is not working try the following query.

SELECT TABLENAMES "NAME", NVL(COUNT(TABLEAPPNO),0) "APP NO"
FROM TABLENAMES, TABLEAPPNO
WHERE TABLENAMES.IDEING=TABLEAPPNO.IDERES(+)
AND (VRPT_TABPRO.DATOUV BETWEEN TO_DATE('20040301','YYYYMMDD') AND TO_DATE('20040331','YYYYMMDD')
Union
SELECT TABLENAMES "NAME", NVL(COUNT(TABLEAPPNO),0) "APP NO"
FROM TABLENAMES, TABLEAPPNO
WHERE TABLENAMES.IDEING=TABLEAPPNO.IDERES(+)
AND VRPT_TABPRO.DATOUV is Null

Here I used the union clause and changed the where condition in the second sql statement, both statements are same, only the where condition is changed in the second conditon.

Hope this will solve your problem.

Regards
Krishna Reddy M
mckreddy@visualsoft-tech.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top