SELECT a.cell_field_name,b.lang_text_value,a.cell_template,a.cell_visible,a.cell_widthFROM sys_grid_properties as a left join
sys_langs as b on
a.lang_menu_code = b.lang_menu_code and
a.cell_display_name = b.lang_text_code
Format the HQL properly. Why is there no space before the "FROM" command?
Related
I am trying to join three tables using a sub query.
The result of the first left outer join is to be used with another table to get a composite view with all attributes.
I am getting an error where the compile says, Unknown Command for the table in the second join clause.
When I create two independent views and then join then it works fine.
(select
l.ENROLLED_CONTENT,
l.LEARNING_ENROLLMENT_LEARNER,
l.EMPLOYEE_ID,
l.JOB_FAMILY_GROUP,
l.EMPLOYEE_TYPE,
l.JOB_FAMILY,
l.LEARNING_ENROLLMENT,
l.COMPLETION_STATUS,
l.COMPLETION_DATE,
l.EXPIRATION_DATE,
l.CF_LRV_LEARNING_CONTENT_NUMBER,
l.LEARNING_CONTENT_DETAIL,
l.LEARNING_CONTENT_TYPE,
l.LESSON_TYPE,
e.id# "WK_WORKER_ID"
from tgt_workday.learning l
left outer join ods_hrmaster.employee e
on l.EMPLOYEE_ID = e.employee#) t1
left outer join ( select
per_ids_id,
per_id,
id_pureid from
ods_pure.person_ids
) t2 on t1.wk_worker_id = t2.value where t2.type = 'Employee ID';
You can write it in a simple way. There is no need to make sub-queries as:
SELECT L.ENROLLED_CONTENT,
L.LEARNING_ENROLLMENT_LEARNER,
L.EMPLOYEE_ID,
L.JOB_FAMILY_GROUP,
L.EMPLOYEE_TYPE,
L.JOB_FAMILY,
L.LEARNING_ENROLLMENT,
L.COMPLETION_STATUS,
L.COMPLETION_DATE,
L.EXPIRATION_DATE,
L.CF_LRV_LEARNING_CONTENT_NUMBER,
L.LEARNING_CONTENT_DETAIL,
L.LEARNING_CONTENT_TYPE,
L.LESSON_TYPE,
E.ID# "WK_WORKER_ID"
FROM TGT_WORKDAY.LEARNING L
LEFT OUTER JOIN ODS_HRMASTER.EMPLOYEE E
ON L.EMPLOYEE_ID = E.EMPLOYEE#
LEFT OUTER JOIN ODS_PURE.PERSON_IDS T2
ON E.ID# = T2.VALUE
AND T2.TYPE = 'Employee ID';
Once you use the outer joined table's column in WHERE clause, It will result in the same result as inner join(there is another ways to use it in WHERE clause though). So it is better to avoid using outer joined table's column in the WHERE clause.
Try as
SELECT *
FROM ( (SELECT l.ENROLLED_CONTENT,
l.LEARNING_ENROLLMENT_LEARNER,
l.EMPLOYEE_ID,
l.JOB_FAMILY_GROUP,
l.EMPLOYEE_TYPE,
l.JOB_FAMILY,
l.LEARNING_ENROLLMENT,
l.COMPLETION_STATUS,
l.COMPLETION_DATE,
l.EXPIRATION_DATE,
l.CF_LRV_LEARNING_CONTENT_NUMBER,
l.LEARNING_CONTENT_DETAIL,
l.LEARNING_CONTENT_TYPE,
l.LESSON_TYPE,
e.id# "WK_WORKER_ID"
FROM tgt_workday.learning l
LEFT OUTER JOIN ods_hrmaster.employee e
ON l.EMPLOYEE_ID = e.employee) t1
LEFT OUTER JOIN
(SELECT per_ids_id, per_id, id_pureid FROM ods_pure.person_ids) t2
ON t1.wk_worker_id = t2.VAL AND t2.TYPE = 'Employee ID')
I'm searching for Linq left outer join query syntax, and I'm struggling to find a good answer for that. My specific SQL query is:
Select tblBpGood.barcode, tblBPGood.Code, Name, RetailPrice, GoodGroupID, tblBPGoodGroupL.Description,
PurchaseUnitTypeID, SalesUnitTypeID, tblBPUnitTypeL.Description as SalesUnitType,
tblBPUnitTypeL_1.Description as PurchaseUnitType
from tblBPGood
left outer join tblBPGoodGroupL
on tblBPGood.GoodGroupID = tblBPGoodGroupL.ID
left outer join tblBPUnitTypeL
on tblBPGood.SalesUnitTypeID = tblBPUnitTypeL.id
left outer join tblBPUnitTypeL as tblBPUnitTypeL_1
on tblBPGood.PurchaseUnitTypeID = tblBPUnitTypeL_1.id
I get this error for the below query when I am trying to make a left outer join
ERROR at line 7:
ORA-00936: missing expression
select s.FINAL_BSAL,s.EMP_No,p.ERN_DDCT_CATNO,p.AMOUNT,n.NO_PAY_AMOUNT,
p.Pay_month,a.ARREARS_AMOUNT from salary_details s,pay_details p,Arrears a,No_Pay n
where s.emp_no=p.emp_no
and
s.SAL_NO IN (SELECT MAX(SAL_NO) FROM SALARY_DETAILS group by EMP_NO)
AND
to_char(P.PAY_MONTH,'MM-YYYY') =to_char(n.NO_PAY_MONTH,'MM-YYYY') (+)
AND
to_char(P.PAY_MONTH,'MM-YYYY')=to_char(a.ARREARS_MONTH,'MM-YYYY') ;
Please help.
The issue lies with the placement of (+):
Instead of:
to_char(P.PAY_MONTH,'MM-YYYY') =to_char(n.NO_PAY_MONTH,'MM-YYYY') (+)
you should do:
to_char(P.PAY_MONTH,'MM-YYYY') =to_char(n.NO_PAY_MONTH (+),'MM-YYYY')
However, if I were you, I'd go with #Walter_Ritzel's approach and use ANSI JOIN syntax instead. That and properly format the SQL so that it's readable...
Try this:
select s.FINAL_BSAL
,s.EMP_No
,p.ERN_DDCT_CATNO
,p.AMOUNT
,n.NO_PAY_AMOUNT
,p.Pay_month
,a.ARREARS_AMOUNT
from salary_details s inner join pay_details p on s.emp_no = p.emp_no
inner join Arrears a on to_char(P.PAY_MONTH,'MM-YYYY')= to_char(a.ARREARS_MONTH,'MM-YYYY')
left outer join No_Pay n on to_char(P.PAY_MONTH,'MM-YYYY') = to_char(n.NO_PAY_MONTH,'MM-YYYY')
where s.SAL_NO IN (SELECT MAX(SAL_NO) FROM SALARY_DETAILS group by EMP_NO);
The below code is written to get the all the parent and child relationship and want to understand why the And is not filtering the records but where does.
e.g-
select
s.name,
s.status,
s.start_date_active,
s.end_date_active,
s.salesrep_number,
p.name Parent_name,
p.status Parent_status,
p.start_date_active Parent_start_date_active,
p.end_date_active Parent_end_date_active,
FROM XXX_XX_SALESREPS s
left outer join XXX_XX_SALESREPS p
on s.attribute1 = p.salesrep_id
**and s.attribute1 = '100003916'**
this above query give all the rows from table s and do not filter it on '100003916' . But when i used ..
select
s.name,
s.status,
s.start_date_active,
s.end_date_active,
s.salesrep_number,
p.name Parent_name,
p.status Parent_status,
p.start_date_active Parent_start_date_active,
p.end_date_active Parent_end_date_active,
FROM XXX_XX_SALESREPS s
left outer join XXX_XX_SALESREPS p
on s.attribute1 = p.salesrep_id
**where s.attribute1 = '100003916'**
this query gives me just filter record. Why can anyone please answer it. Thanks in advance.
In your first case and s.attribute1 = '100003916' is part of your join criteria - and since it is left outer join it wont serve as a filter.
I'm new to linq and I'm having trouble getting the correct syntax for this sql statement.
SELECT
A.AssetName,
B.MPercentage,
B.OPercentage,
B.IsStateDefault,
D.ShortName
FROM [Core].[dbo].[Asset] A
FULL OUTER JOIN [Core].[dbo].[PayrollMarkup] B
ON A.PayrollMarkupID = B.PayrollMarkupID
FULL OUTER JOIN [Core].[dbo].[StatePayrollMarkup] C
ON B.PayrollMarkupID = C.PayrollMarkupID
FULL OUTER JOIN [Core].[dbo].[StateLookup] D
ON C.StateID = D.StateID
WHERE A.AssetName IS NOT null