cancel
Showing results for 
Search instead for 
Did you mean: 

Query

Former Member
0 Kudos

Hi

  I have written this query

SELECT a.Code, a.Name , b.U_Amount as Amount FROM [@TEMP]a left JOIN [@TEMP1]b ON a.Code = b.U_Al_Code left join ohem c on c.empid = 1

There are 4 records in Table 1 & 2 records in Table 2  of ID 1 . I want all the 4 records to be displayed and value in Amount in only 2 records as there are only 2 records with amount value of ID 1.

Above query is showing all 4 records from Table 1 and Amount Value also in 4 records but there are only 2 records in second table.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

kothandaraman_nagarajan
Active Contributor
0 Kudos

Hi,

Use where condition in above query.

For example

Where T1.table ID 1 = T2 table ID1

Regards,

Nagarajan

Answers (2)

Answers (2)

kothandaraman_nagarajan
Active Contributor
0 Kudos

Hi,

Try this:

SELECT T0.[empID], T0.[firstName], T0.[lastName], T0.[sex], T0.[jobTitle], T0.[type], T0.[dept], T0.[branch], T0.[workCountr], T0.[manager], T0.[mobile], T0.[homeTel], T0.[startDate], T0.[homeCountr], T0.[homeState], T0.[brthCountr], T0.[martStatus], T0.[citizenshp], T0.[passportNo], T0.[passportEx]

FROM OHEM T0

WHERE T0.[Active] = 'y'

Thanks & Regards,

Nagarajan

Former Member
0 Kudos

Hi NagaRajan

      I want where clause in this query on EmpId . E.g where T0.empid = variable value . This value will be dynamic

Thanks

kothandaraman_nagarajan
Active Contributor
0 Kudos

Hi,

SELECT T0.[empID], T0.[firstName], T0.[lastName], T0.[sex], T0.[jobTitle], T0.[type], T0.[dept], T0.[branch], T0.[workCountr], T0.[manager], T0.[mobile], T0.[homeTel], T0.[startDate], T0.[homeCountr], T0.[homeState], T0.[brthCountr], T0.[martStatus], T0.[citizenshp], T0.[passportNo], T0.[passportEx]

FROM OHEM T0

WHERE T0.[Active] = 'y' and T0.[empID] = [%0]

Thanks & Regards,

Nagarajan

Former Member
0 Kudos

Hi NagaRajan

   Thanks . Can u help me if i want to write this query through SDK. In SDK i don't think above query will work.

Thanks

Former Member
0 Kudos

hello sunny,

As much i understand your problem, try this u may get desire output.

SELECT a.Code, a.Name , b.U_Amount as Amount FROM [@TEMP]a INNER JOIN [@TEMP1]b ON a.Code = b.U_Al_Code left join ohem c on c.empid = 1

thanks

vikas

Former Member
0 Kudos

Hi Vikas

  Just help me i want to display all data of current employee record  in Employee Master .

Employee ID will be dynamic.

Thanks