thanks brother for ur reply
but i think u don't understand my problem:
now i am paste my query and output here:
query:
Select title+' '+UPPER(SUBSTRING(FirstName,1,1)) + LOWER(SUBSTRING(FirstName,2,LEN(FirstName)))+' '+
UPPER(SUBSTRING(MidName,1,1)) + LOWER(SUBSTRING(MidName,2,LEN(MidName)))+' '+
UPPER(SUBSTRING(LastName,1,1)) + LOWER(SUBSTRING(LastName,2,LEN(LastName))) as name,d.desg_name as olddesignation,
CONVERT(CHAR(11),dateadd(yy,pd.yearsexp,p.dt_last_ prom),106) as promotiondue,
d1.desg_name as newdesignation
From personnel p,promotiondue pd,qualification q,designation d,designation d1
where p.Ser_Type= 'S' and p.I_code= 83
and p.desg_code=pd.desgcode and p.emp_code=q.emp_code and q.qual_Type=pd.educriteria
and pd.desgcode = d.desg_code and pd.promotedto = d1.desg_code
and getdate() < dateadd(yy,pd.yearsexp,p.dt_last_prom)
order by name
output:
name olddesgintaion promotedto newdesignation
Dr Dharam Raj Singh Scientist 22 Jan 2010 Scientist S.S
Dr Dharam Raj Singh Scientist 22 Jan 2008 Scientist S.S
Dr Rajender Parsad Sr.Scientist 23 Jan 2009 Principal Scientist
Dr Seema Jaggi Sr.Scientist 21 Jan 2009 Principal Scientist
Dr Sushila Kaul Sr.Scientist 29 May 2008 Principal Scientist
Mr Hukum Chandra Scientist S.S 19 Dec 2007 Scientist S.G
Smt Alka Arora Scientist S.S 27 Nov 2008 Scientist S.G
in this query dharam raj has done two degreee (msc and phd) .first record show on the basis of msc and second record show on the basis of phd. but i want that only phd record is show there not firstone.
pls help me yaar i m really confuse how to solve this problem.
reply me soon
I'm not sure I understand how your table is set up. I think it looks something like this:
-
Name designation promotedto newdestin
-
------------------- ----------- ----------- -------------
-
Dr Dharam Raj Singh Scientist 22 Jan 2008 Scientist S.S
-
Dr Dharam Raj Singh Scientist 22 Jan 2010 Scientist S.S
-
SELECT DISTINCT will only show one row when it encounters multiple rows that have the same value in the GROUP BY clause. So if you wanted to get unique names, you would use the query I provided in the last post (though you'd probably need to change `tableName` to the whatever your table is actually named).
If you had people with the same name, and you wanted to differentiate further, you might need to add another column to the GROUP BY clause (e.g., SELECT DISTINCT * FROM `tableName` GROUP BY `name`, `designation`).