Hi there,In Navision, they have
global dimension 1 code which table related to dimension value.code with condition global dimension = 1 and global dimension 2 code which table related to dimension value.code with condition global dimension = 2
I want to create report with query
Select posting date, global dimension 1 as department code, global dimension 2 as project code from G\L Entry
i get record with empty data for both global dimension code
right now i dont know how retrieve data for both global dimension code which same condition.
i had try to do (who knows it work)
Select [Posting Date], [Global Dimension 1 Code]
[select Code as [Department name] from [CRONUS Malaysia Sdn_ Bhd_$Dimension Value] where ([Global Dimension No_]=1)],[Global Dimension 2 Code] [SELECT Code AS [Department name] FROM [CRONUS Malaysia Sdn_ Bhd_$Dimension Value]
where ([Global Dimension No_]= 2)]
from [CRONUS Malaysia Sdn_ Bhd_$G_L Entry]
error msg:
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near ']'.
any idea..?
Thank you
0
Comments
Do you need also the names of the Dinension codes?
Your query is more then bad ;-)
Here the solution with the names.
The result set is:
Do you need this?
I guess it should be ...
... then it should be syntactically correct (haven't tested). But I'm not sure if this is really what you want; if I understood you right, you want something like this:
Does this work?
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool
i had try both stryk and garak code but i prefer to use stryk code.
Thanks to garak too, your code also give me an idea to solve another prob...
but i still thinking what wrong with my syntax?
Select [Posting Date],
(select Code as [Department name] from [CRONUS Malaysia Sdn_ Bhd_$Dimension Value] where ([Global Dimension No_]=1)),
(SELECT Code AS [Project name] FROM [CRONUS Malaysia Sdn_ Bhd_$Dimension Value] where ([Global Dimension No_]= 2))
from [CRONUS Malaysia Sdn_ Bhd_$G_L Entry]
I got error:
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
What wrong with that? :-k
If you want to see what they are returning, run the subqueries as separate queries and see what results they are returning.
The left joins in the earlier examples return just the matching value for that entry if it exists.
http://mibuso.com/blogs/davidmachanick/
I also search sql tutorial in the net, I found the syntax like this:
SELECT pno, qty, (SELECT city FROM s WHERE s.sno = sp.sno)
FROM sp
that why I relly want to try..
but i guess i better to use left join..its easy..