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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

So simple but it is not working! Help!

Status
Not open for further replies.

skss

Programmer
Oct 7, 2003
22
0
0
HK
select count(*)
from order_header, order_detail
where order_header.ORDER_NO = order_detail.ORDER_NO
and order_header.ORDER_STATUS = '14'

I have checked and there are 19556 records from the header file whose status = 14 and and there are a total of 96920 records in the detail file. From what I understand, the query above should give me a portion out of the 96920 records whose order_no corresponds to the order_no from the header file whose status = 14. However, when I run the query I get 194178 records. Isn't that impossible or did I miss something?
 
Is 14 supposed to be a numerical or string value? If numeric, try it without the single quotes.

Also, if the query is based only on a count of values matching a criterion in order_header, you don't need to join order_detail in the query at all.

Try:
select
count(*)
from
order_header
WHERE
ORDER_STATUS = 14



Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top