Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why this query doesn't return all Queue records?
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Why this query doesn't return all Queue records?
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01078686
Message ID:
01078686
Views:
45
Hi everybody,

Here is the query
SELECT CAST(NVL(COUNT(*), 0) as Numeric(5,0)) as nCount, ;
	Queue_Names.cQueue_Names_pk, Queue_Names.cQueue_Name, 
	Trans.cDepartment_Code
	FROM Queue_Names
	LEFT JOIN Trans_Employees_Queues on 
	Queue_Names.cQueue_Names_pk = Trans_Employees_Queues.cQueue_Names_fk 
	LEFT JOIN Trans on Trans.cTrans_pk = Trans_Employees_Queues.cTrans_fk	
	where Queue_Names.iActive_Flag = 1 and Trans_Employees_Queues.iActive_Flag = 1 
	group by 2,3,4
It returns only 3 records for the 3 queue names I have in Trans_Employees_Queues table. I would expect it to return all possible queue names from Queue Names table with 0 as count. Do you see what's the error in my logic?

Thanks in advance.

Ok, now I think I see it myself. I should not group by Department code or how should I modify it? Simple - by using either Trans department code or by using Queue department code, since we have it in both tables.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform