'Date of Joining' in PE51
Hi,
I would like to add 'Date of Joining' in the payslip. I am using PE51. Any idea about how o do this?
Thanks
Hi Dear,
as per my knowledge,the date of joining come from IT0001.In It0001 we have start date and end date,in statement wise we need to add these field in table t514n.please take help from your abap concultant.
Thanks&Regards
B4SAPHCM
Similar Messages
-
Date of joining is not showingup in the payslip...
Hi Experts,
In ourpayslip,the date of joinging is picking up from the latest org.assignemnt date.
It has to come from 0041 IT.In the single fields it is showing 0001 so it is showinup in recent org reassignment date.
But it has to pick from IT 0041 with DATETYPE U1 (Hire date)
What should we mention the Single field Date of joining of PE51 .....Im confident that The table should be P0041
Here my question is What should be the table field and output length.
Could u please check the PE51 and let me know the what could be the table field and output length to be maintained to extract from the datetype U1.
Please advice.
Regards,
Sai.sai
I advice you to check this one on ur own as the cloumn and rows length will differe from each other form
so test it play with and go ahead
all the best -
Need to change the date of joining of employee
Hi All,
I have gone through some threads similar to this subject an also tried to do changes from PA41 but i am facing some problems during the procedure.
We have transferred some employees to sap system with their original date of joining and payroll was run from some other date for those employees. So i need to change the date of joining of those employees.
For example : Below is the line items of one employee from table infotype 0.
End date Start date Changed on
22.02.2009 19.02.2007 19.02.2009
31.03.2009 23.02.2009 19.02.2009
31.12.2009 01.04.2009 14.10.2009
31.12.9999 01.01.2010 21.01.2010
Payroll was run from Feb-09 onwards and i want put date of joining for this employee as 23.02.2009.
I want to know which date i need to change??...When i am trying to change the first start date i.e. 19.02.2007 to my desired start date, but it is not allowing me to do that as end date is smaller.
Please tell me how would i change the joining date of employee as 23.02.2009 ?.
Thanks.Try this
22.02.2009 19.02.2007
31.03.2009 23.02.2009
31.12.2009 01.04.2009
31.12.9999 01.01.2010 take this record form PA30 IT0000 Over View (Shif + F8) Copy that record and change the Start date
as 2302.2010 so another record will be created
22.02.2010 01.01.2010
31.12.9999 23.02.2010
Just try and let me know -
hi sap gurus.
i wanted to change the date of joining of an employee(assue that an employee is already hired in to the system from 1980. only hiring action has been taken place no pay roll has been run.) in this case i want to change that employee joining date from 2007 april.i tried it through the pa41 t code but its giving some error saying some earliest date changes are not allowed.
can any one tell me the procedure exactly how to change the hiring date of an employee.and aslo the possibility of deleting the personal number and re-hiring the person for same p no with our choice date.
thanks in advance
thanks & regards
eshwarhai
u mean to say that the employee hiring date is 1980 and change it to 2007
any way when hiiring action takes place a payroll status is record is created IT0003.
if u r planning to change the date beyond the dtae that is stored in your control record it will not accept.
if u delete the personnel number altogether u can as suggested
but i dont know or i dont think u can get the number again if the number range is internal.
one thing u can do is change the control record earliest retrodate to your need and change the date
then set it back to th original date
regards
nalla
ps: first try this in development -
Dear Team,
In our client, some of employee date of Joining & date of birth wrong mentioned, how to correct the date of joining & date of birth.
Kindly suggest!
Regards,
RakeshHi,
We seem to be in the usual SCN mess of having a very unspecific question followed by answers based on guesses and assumptions ;-)
Can you please specify exactly how the problem manifests itsself?
Are entry date and date of birth just shown wrongly in a report (which one - report name please) or in a query / ad-hoc query (which fields are you using - technical names please)?
Are you using fields in infotype 0016 or 0041 intended to overwrite the entry date from the hiring action?
Does the system show an entry date from a start date from a different action, which is not hiring?
Does the problem occur for re-hires only?
Does the ststem show the date from the hiring action correctly, but you want it to show something differnt?
OR: do you really want to move the start date of the infotype 0000 record of the hiring action and how do you want payroll to respond to this. This case would be a bit of a disaster, but I believe and hope this is not what you need. If you only want a differen entry date to be shown in reports or elsewhere for info purposes, there's really noooo need to do this.
If you can clarify your question, I'm confident many SCN members can help you effectively.
Kind regards
Sven -
Subtract date of joining from date of birth
i have date of joining and date of birth in a table i need o subtract these both what should i do for these task
If you substract two dates, you will get number of days. You can convert it to get years or use Months_Between function to the number of months between two dates and calculate it to get years or use extract function to just get the years difference (if you just want to get years difference without worrying about actual year).
-
Infoset doc no. and item data Outer Join Problam
HI Gurus,
I am using infoset based on 2 ODS 0figl_o02 and 0fiap_o03 for queiry.
I have a requirment like ...
0fiap_o03
doc no. item amount vendor
3333 1 10000 101
3333 2 20000 101
0figl_o02
doc no. item amount
3333 1 10000
3333 2 20000
3333 3 30000
3333 4 40000
3333 5 50000
Now data required in Infoset
doc no. item amount vendor
3333 1 10000 101
3333 2 20000 101
3333 3 30000 101
3333 4 40000 101
3333 5 50000 101
i am currently join it with company code and doc no.
plz provide me your input to get above data in infoset.
null
Message was edited by:
SSMS
Message was edited by:
SSMS
nullThanks Phani,
I joined item and did outer join.
data is not coming as required.
is that the way to apply outer join.????
Message was edited by:
SSMS -
DB connectivi​ty toolkit: syntax error in a SELECT data from joined tables
Hello everyone
I'm trying to put in labview an SQL query on joined tables.
As example I take a DB for storing the data of 2on2 basketball games, whose tables are
matches(matchId,teamA,teamB)
teams(teamId,PlayerAname,PlayerBname,Nationality)
nationalities(NatId,natName)
To get a result table with the match number and the player names along with their nationality I use this query on MySQL (which works on the command line interface)
SELECT MatchID,
t1.PlayerAName, t1.PlayerBName, n1.natName,
t2.PlayerAName, t2.PlayerBName, n2.natName
FROM matches m
INNER JOIN teams t1 ON t1.teamID = m.teamA
INNER JOIN teams t2 ON t2.teamID = m.teamB
INNER JOIN nationalities n1 ON n1.natID = t1.nationality
INNER JOIN nationalities n2 ON n2.natID = t2.nationality
When I put it in labview, using the "select data" block, I get a syntax error as shown in the attached screenshot.
Am I mistanking something in using the JOIN statements, or the aliases?
Thanks in advance!
Solved!
Go to Solution.
Attachments:
select2dabone.vi 12 KBGiovasa wrote:
I do't like very much the chain of blocks execute query+n*(fetch element)+free object, so I try to avoid that as much that I can...
Sounds like a prime candidate for a subVI. You don't have to use it every time, but it probably would help for cases where you do want to put the SQL query directly in code.
Incidentally, if you're doing joins, you might consider using views, as that allows you to hide the details of the interactions of the tables in the DB itself.
Try to take over the world! -
Get desired data from joining multiple tables
I have the following query which is returning some data.
SELECT i.IssueId, i.IssueDesc, i.MainRecId, a.PlantId
FROM Issues i INNER JOIN PlantPcontact pp ON i.SubmitterId = pp.PContactId
INNER JOIN Plant a ON a.PlantId = pp.PlantId
WHERE (a.PlantStatus = 1)
ORDER BY i.IssueId
I need to join i.MainRecId and a.PlantId from the results of this query with another table PlantDoc (pd) ON PDMainRecId and PDPlantId respectively (one-to-one relationship) and retrieve additional information (pd.PlantDocId).
How do I accomplish everything in one single query ?
I am looking for the following data finally.
i.IssueId, i.IssueDesc, i.MainRecId, a.PlantId, pd.PlantDocIdExample for JOINs with many tables:
http://www.sqlusa.com/bestpractices/fourtablejoin/
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012 -
How to change Date of joining in Oracle Apps Hrms?
While employee data migration i have entered incorrect original date of hire.Now ,i want to correct it to system date.
I'm using 'hr_person_api.update_person' to correct the date but not able to do.So, can any let me know how i can do that from backend.When you say "you are not able to"...what error messages are you getting back from the API?
If its to correct a single person then its easier to do this via the front end application forms.
Regards
Barry -
Q41 IWrong sales order data when joining to purchase order
No matter what I try I am getting sales order numbers that are not relevant to the purchase order number, I suspect it is to do with the joins but can't figure it out..............
SELECT
t2.cardcode as 'Customer',
t2.docnum as 'Sales Order',
t0.docnum as 'Purchase Order',
t0.docduedate,
t1.itemcode,
t1.dscription as 'Item Description',
t1.quantity
FROM
opor t0
inner join por1 t1 on t0.docentry = t1.docentry
inner join ordr t2 on t0.docentry = t2.docentry
WHERE
t0.docduedate >= '[%0]' and
t0.docduedate <= '[%1]' and
t1.itemcode >= '[%2]' and
t1.itemcode <= '[%3]' and
t1.whscode = 'DSHP'
As always any help greatly appreciated.
RobinUpdated:
SELECT Distinct
t3.cardcode as 'Customer',
t3.docnum as 'Sales Order',
t0.docnum as 'Purchase Order',
t0.docduedate,
t1.itemcode,
t1.dscription as 'Item Description',
t1.quantity
FROM
opor t0
inner join por1 t1 on t0.docentry = t1.docentry
inner join rdr1 t2 on t2.PoTrgentry = t0.docentry
inner join ordr t3 on t2.Docentry = t2.docentry
WHERE
t0.docduedate >= '[%0]' and
t0.docduedate <= '[%1]' and
t1.itemcode >= '[%2]' and
t1.itemcode <= '[%3]' and
t1.whscode = 'DSHP' -
Issue with select query to fetch data using Join from two tabels
Hello All-
I want to fetch the ShowName as "SUN NIGHTLY NEWS" and EpisodeName as "091706"
based on the condition a.TitleNo=b.TitleNo and a.seriesNo=b.TitleNo.
If i use the only first condition-a.TitleNo=b.TitleNo than output is displayed as-
SchedItemNo | Showname| EpisodeName
2702154 | 091706 | 091706
If i use the second Condition-a.seriesNo=b.TitleNo than Output is displayed as-
SchedItemNo| Showname | EpisodeName
2702154 | SUN NIGHTLY NEWS | SUN NIGHTLY NEWS
Than i tried following Query to use the Union based on two conditions:-
Select distinct a.SchedItemNo,b.TitleName,b.TitleName as EpisodeName
from ScheduleItem a,Titles b where a.TitleNo=b.TitleNo and
a.ScheditemNo in ('2702154')
Union All
Select distinct a.SchedItemNo,b.TitleName,b.TitleName as EpisodeName
from ScheduleItem a,Titles b where b.TitleNo=a.SeriesNo and
a.ScheditemNo in ('2702154')
than it display the following result-
SchedItemNo| Showname | EpisodeName
2702154 | 091706 | 091706
2702154 | SUN NIGHTLY NEWS | SUN NIGHTLY NEWS
Here also values are not what i want :(
I want the result to be displayed as using SQL:-
SchedItemNo | Showname | EpisodeName
2702154 | SUN NIGHTLY NEWS | 091706
Please help me out!
Thanks in Advance for putting your efforts.Looking forward for your replies.SQL> create table scheduleitem
2 as
3 select 2702154 scheditemno, 1 titleno, 11 seriesno from dual
4 /
Tabel is aangemaakt.
SQL> create table titles
2 as
3 select 1 titleno, '071706' titlename from dual union all
4 select 11, 'SUN NIGHTLY NEWS' from dual
5 /
Tabel is aangemaakt.
SQL> Select distinct a.SchedItemNo,b.TitleName,b.TitleName as EpisodeName
2 from ScheduleItem a,Titles b where a.TitleNo=b.TitleNo and
3 a.ScheditemNo in ('2702154')
4 /
SCHEDITEMNO TITLENAME EPISODENAME
2702154 071706 071706
1 rij is geselecteerd.
SQL> Select distinct a.SchedItemNo,b.TitleName,b.TitleName as EpisodeName
2 from ScheduleItem a,Titles b where b.TitleNo=a.SeriesNo and
3 a.ScheditemNo in ('2702154')
4 /
SCHEDITEMNO TITLENAME EPISODENAME
2702154 SUN NIGHTLY NEWS SUN NIGHTLY NEWS
1 rij is geselecteerd.
SQL> Select distinct a.SchedItemNo,b.TitleName,b.TitleName as EpisodeName
2 from ScheduleItem a,Titles b where a.TitleNo=b.TitleNo and
3 a.ScheditemNo in ('2702154')
4 Union All
5 Select distinct a.SchedItemNo,b.TitleName,b.TitleName as EpisodeName
6 from ScheduleItem a,Titles b where b.TitleNo=a.SeriesNo and
7 a.ScheditemNo in ('2702154')
8 /
SCHEDITEMNO TITLENAME EPISODENAME
2702154 071706 071706
2702154 SUN NIGHTLY NEWS SUN NIGHTLY NEWS
2 rijen zijn geselecteerd.
SQL> select a.SchedItemNo "SchedItemNo"
2 , show.TitleName "Showname"
3 , episode.TitleName "EpisodeName"
4 from ScheduleItem a
5 , Titles episode
6 , Titles show
7 where a.TitleNo = episode.TitleNo
8 and a.SeriesNo = show.TitleNo
9 /
SchedItemNo Showname EpisodeName
2702154 SUN NIGHTLY NEWS 071706
1 rij is geselecteerd.Regards,
Rob. -
I have a bad universe or a data design issue.
Several versions of hierarchies reporting store entities in reporting Fact measures.
Example of date driven Hierarchy Dimension: ORG_KEY
START_DATE
END_DATE
STORE_NUMBER
ORG_HIERARCHY
CURR_FLG (Y/N)
Fact table : ORG_KEY
CALENDAR_KEY
TRANS_DATE
$amount
Calendar Dimension: CALENDAR_KEY
DAY_DATE
FY_WEEK (201452)
FY_PERIOD (201412)
FY_QUARTER (201401)
FISCAL_YEAR (2014)
Users WISH:
Wish for store number and org hierarchy to pull as of the last day of each pull without prompt. The Store(ORG_KEY) as in the fact table; but the ORG_HIERARCHY and other attributes as of the last day they pull.
Daily (Would be Calendar.Day_Date in Filter) ,
Week to date (would be Max Calendar.Day_Date for (201452) FY_WEEK as entered,
Month to date,
Year to date,
AdHoc queries.
My problem is I see how they could manually pull this in Webi. I have tried everything I know to join to no avail. I have not gotten @Prompts to work in joins, derived tables, etc. in the data foundation. Wonder what is difference between parameter in Data foundation vs. filter in buisness layer. None of them worked.
Please help! ANY ideas would be appreciated. .{Note that abbrevations in brackets are just for short form further down the answer}
Join Store Dim (SD) to Transaction Fact (TF) on ORG_KEY=ORG_KEY with 1 to Many cardinality
Create an alias of Calendar Dim and call it Transaction Date (TD)
Join TD to TF on TD.CALENDAR_KEY=TF.CALENDAR_KEY with 1 to Many cardinality
Create a predefined condition in your universe called "Return Yesterday's Transactions" as:
TD.DAY_DATE = trunc(sysdate-1) <-- That assumes Oracle database; use whatever is correct for yesterday for your RDBMS
The above predefined condition when added to your data query will return only yesterday's transactions.
However, if you want to return all the different types of sales, you would need an object for each one. To do that, you'd use a case statement. Again, using Oracle syntax, an example of MTD would be:
SUM(CASE WHEN trunc(TD.DAY_DATE,'yyyymm') = trunc(sysdate,'yyyymm') THEN TF.amount END)
If you have any more questions about how this approach would work please shout.
As an alternative, you could create a time hierarchy and add scope of analysis to your report for it and enable drilling at report level. -
Outer join two different dates
I have a table that has some pre-aggregated dollar amounts. Each record also has a date of fill and a file date. I want to sum all records in the table by year/month of fill date and separately I want to use the same query results to sum by year/month
of file date. The problem I was initially having was that the query was not showing all dates January through December, but instead was only showing dates for which there was a record. Makes sense, I get it, and I fixed that by using a cross join
on a date table and left join on that table. See below. Pretty simple really. My results have a record for every file date and a $0 amount if there is no file for that date. However, I want the same thing for fill date. If I don't
have a file for January but I do have a fill for that date then I want to display that year/month with the dollar amount. I hope this makes sense.
The approaches I have tried thus far are to add a separate CTE for the fill date, joining to the same CTE twice (once for fill and once for file), and some crazy unions... all with no luck.
Can anyone help me out please?
Thanks!
WITH dt
AS (SELECT cdb.ID,
cdb.RestoreDBName,
cdb.DisplayName,
d.Date
FROM DataOperations.lkp.Dates AS d CROSS JOIN DataOperations.dbo.vwClientDatabases AS cdb
WHERE d.Date BETWEEN '01-01-2013' AND DATEADD(day, -1 * DAY(CAST(GETDATE() AS DATE)), DATEADD(month, 1, CAST(GETDATE() AS DATE)))
AND d.DayOfMonth = 1
SELECT dtFile.RestoreDBName,
dtFile.ID,
YEAR(dtFile.Date) AS FileYear,
MONTH(dtFile.Date) AS FileMonth,
dtFile.Date AS FileDate,
LEFT(CONVERT(VARCHAR, dtFile.Date, 120), 7) AS FileYearMonth,
YEAR(rx.FillDate) AS FillYear,
MONTH(rx.FillDate) AS FillMonth,
CAST(CONVERT(VARCHAR, YEAR(rx.FillDate)) + '-' + CONVERT(VARCHAR, MONTH(rx.FillDate)) + '-01' AS DATE) AS FillDate,
LEFT(CONVERT(VARCHAR, rx.FillDate, 120), 7) AS FillYearMonth,
ISNULL(SUM(rx.TotalPayAmount), 0) AS TotalPayAmount
FROM dt AS dtFile LEFT JOIN DataOperations.rpt.RxGrossPayAmountByDay AS rx ON rx.DBName = dtFile.RestoreDBName
AND DATEADD(month, DATEDIFF(month, 0, rx.TapeFileDate), 0) = dtFile.
[Date]
LEFT JOIN DataOperations.dbo.vwClientDatabases AS cdb ON cdb.RestoreDBName = rx.DBName
GROUP BY dtFile.RestoreDBName,
dtFile.ID,
YEAR(dtFile.Date) ,
MONTH(dtFile.Date) ,
dtFile.Date ,
LEFT(CONVERT(VARCHAR, dtFile.Date, 120), 7) ,
YEAR(rx.FillDate) ,
MONTH(rx.FillDate) ,
CAST(CONVERT(VARCHAR, YEAR(rx.FillDate)) + '-' + CONVERT(VARCHAR, MONTH(rx.FillDate)) + '-01' AS DATE),
LEFT(CONVERT(VARCHAR, rx.FillDate, 120), 7)
ORDER BY dtFile.RestoreDBName, YEAR(dtFile.Date), MONTH(dtFile.Date)Ok, how about this.
WITH dtFile
AS (SELECT dt.RestoreDBName,
YEAR(dt.Date) AS Year,
MONTH(dt.Date) AS Month,
ISNULL(SUM(rx.TotalPayAmount), 0) AS TotalPayAmount
FROM(
SELECT cdb.ID,
cdb.RestoreDBName,
cdb.DisplayName,
d.Date
FROM DataOperations.lkp.Dates AS d CROSS JOIN DataOperations.dbo.vwClientDatabases AS cdb
WHERE d.Date BETWEEN '01-01-2013' AND DATEADD(day, -1 * DAY(CAST(GETDATE()AS DATE)), DATEADD(month, 1, CAST(GETDATE()AS DATE)))
AND d.DayOfMonth = 1
)AS dt LEFT JOIN DataOperations.rpt.RxGrossPayAmountByDay AS rx ON rx.DBName = dt.RestoreDBName
AND DATEADD(month, DATEDIFF(month,
0, rx.TapeFileDate), 0) = dt.[Date]
GROUP BY dt.RestoreDBName,
YEAR(dt.Date) ,
MONTH(dt.Date) ),
dtFill
AS (SELECT dt.RestoreDBName,
YEAR(dt.Date) AS Year,
MONTH(dt.Date) AS Month,
ISNULL(SUM(rx.TotalPayAmount), 0) AS TotalPayAmount
FROM(
SELECT cdb.ID,
cdb.RestoreDBName,
cdb.DisplayName,
d.Date
FROM DataOperations.lkp.Dates AS d CROSS JOIN DataOperations.dbo.vwClientDatabases AS cdb
WHERE d.Date BETWEEN '01-01-2013' AND DATEADD(day, -1 * DAY(CAST(GETDATE()AS DATE)), DATEADD(month, 1, CAST(GETDATE()AS DATE)))
AND d.DayOfMonth = 1
)AS dt LEFT JOIN DataOperations.rpt.RxGrossPayAmountByDay AS rx ON rx.DBName = dt.RestoreDBName
AND DATEADD(month, DATEDIFF(month,
0, rx.FillDate), 0) = dt.[Date]
GROUP BY dt.RestoreDBName,
YEAR(dt.Date) ,
MONTH(dt.Date)
SELECT dtFile.RestoreDBName,
dtFile.Year AS FileYear,
dtFile.Month AS FileMonth,
dtFill.Year AS FillYear,
dtFill.Month AS FillMonth,
dtFile.TotalPayAmount as FileTotalPayAmount,
dtFill.TotalPayAmount as FillTotalPayAmount
FROM dtFile FULL OUTER JOIN dtFill ON dtFile.RestoreDBName = dtFill.RestoreDBName
ORDER BY dtFile.RestoreDBName, dtFile.Year, dtFile.Month
I think I'm getting close, but there's some odd results for the file total pay amount. Here are the partial results for the first RestoreDBName in my results. I have some repeating and I'm not sure what value to use. Do I use FillTotalPayAmount
PLUS FileTotalPayAmount or one or the other or what? Am I joining on the right fields?
Thank you so much. This is a big help and a great learning lesson too!
FileYear
FileMonth
FillYear
FillMonth
FileTotalPayAmount
FillTotalPayAmount
2013
1
2013
1
655.5
711.7
2013
1
2013
2
655.5
658.5
2013
1
2013
3
655.5
715.2
2013
1
2013
4
655.5
744.5
2013
1
2013
5
655.5
765.8
2013
1
2013
6
655.5
718.8
2013
1
2013
7
655.5
792.8
2013
1
2013
8
655.5
781.4
2013
1
2013
9
655.5
748.6
2013
1
2013
10
655.5
822.4
2013
1
2013
11
655.5
752.2
2013
1
2013
12
655.5
839.0
2013
1
2014
1
655.5
702.9
2013
1
2014
2
655.5
7.3
2013
1
2014
3
655.5
0.0
2013
1
2014
4
655.5
2013
2
2013
1
672.7
711.7
2013
2
2013
2
672.7
658.5
2013
2
2013
3
672.7
715.2
2013
2
2013
4
672.7
744.5
2013
2
2013
5
672.7
765.8
2013
2
2013
6
672.7
718.8
2013
2
2013
7
672.7
792.8
2013
2
2013
8
672.7
781.4
2013
2
2013
9
672.7
748.6
2013
2
2013
10
672.7
822.4
2013
2
2013
11
672.7
752.2
2013
2
2013
12
672.7
839.0
2013
2
2014
1
672.7
702.9
2013
2
2014
2
672.7
7.3
2013
2
2014
3
672.7
0.0
2013
2
2014
4
672.7
2013
3
2013
1
630.6
711.7
2013
3
2013
2
630.6
658.5
2013
3
2013
3
630.6
715.2 -
Unable to retrive data from two tables using multiple joins
Hi,
Table: EMP mgr
eid name
eid mgrid
1
A 1
null
2
B 2
3
3
C 3
3
i need to get result as:
eid ename mgrname
thanks
AVSSai,
It would be very helpful if you could mention your table structures a bit more clearly. Would allow for effective replies from fellow users as well. :)
However, assuming that your structure would be as follows presenting the query as below:
DECLARE @Emp TABLE(Eid Int, ename Varchar(50))
DECLARE @Emp_Mgr TABLE(Eid int, mgrid int null )
INSERT INTO @Emp select 1,'Ram'
INSERT INTO @Emp select 2,'Shyam'
INSERT INTO @Emp_Mgr select 1,NULL
INSERT INTO @Emp_Mgr select 2,1
SELECT * FROM @Emp
SELECT * FROM @Emp_Mgr
Query to print results as EID, ENAME, MGRNAME
SELECT em.eid,e1.ename as ENAME,e2.ename as MGRNAME
FROM @Emp_Mgr em
JOIN @Emp e1 ON em.eid=e1.eid
JOIN @Emp e2 ON em.mgrid=e2.eid
However, as you see this approach of maintaining two tables for preserving the employee-manager data is redundant and makes the queries unnecessarily complex. So, you could opt for the widely used single table format as mentioned by Praveen as well. Check
if this helps you..
Recommended Structure
*Avoidance of redundant storage of data
*Lesser Joins in queries
DECLARE @Emp TABLE(Eid Int , Ename Varchar(50) , mgrid int null )
INSERT INTO @Emp(Eid , ename , mgrid) values(1 , 'Ram' , null) , (2 , 'Shyam' , 1)
SELECT * FROM @Emp
Query to print results as EID, ENAME, MGRNAME
SELECT e.Eid , e.Ename , m.Ename as MgrName
FROM @Emp e
JOIN @Emp m On a.mgrid = b.eid
Thanks,
Jay
<If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>
Maybe you are looking for
-
How can I delete all these mysteriously empty albums
I need to clean out the photos and folders/albums which are in my iPad "Photo" app (NOT iPhoto). For some reason, at some point, folders/albums which previously held photos seem to be empty and grayed out. I want to delete them. I click "Edit" but wh
-
Displaying image from database table.
Hi All, I am very new to Web Dynpro ABAP. I am developing an application to display an image in "Image" UI Element. For this I have one table consisting of fields image id, image data and image name. here image id is primary key field. Now i w
-
Hi, I created an applet that contains a JTable. To control the keys pressed I created a custom FocusManager. Instead of jumping to the next cell in the JTable I add a new line to the content of the table when RETURN is pressed. I didn't find any othe
-
Uploading Kuler Theme into Muse?
I've saved a theme in Kuler, downloaded it as an .asa file. In Muse, I tried to find or upload it from the Library and the asa file is grayed out, not able to select it.
-
HT2476 How do I upgrade from snow leopard 10.6.8 to lion 10.7?
I get an error message when tryin gto access the mac app store from my apple menu and any browser. I want to upgrade to iMovie '11 from '09. I also want to upgrade from snow leopard to lion.