Click here to Skip to main content
15,889,649 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have one table i want to take maximum times repeated value in dcr and leave both column..pls tell me very urgent
type	fscode		cr	leave	flag	
1		MSR042		2	2		0
1		MSR020		2	2		0
3		ZSM010		25	25		0
1		MSR086		2	2		0
1		MSR229		2	2		0
1		MSR150		2	2		0
1		MSR088		2	2		0
1		MSR258		2	2		0
2		ASM018		2	2		0
1		MSR228		2	2		0
1		MSR074		2	2		0
1		MSR241		2	2		0
1		MSR187		2	2		0
2		ASM008		2	2		0
2		ASM014		2	2		0
1		MSR105		2	2		0
1		MSR050		2	2		0
1		MSR256		2	2		0
1		MSR212		2	2		0
1		MSR159		2	2		0
1		MSR209		7	2		0
2		ASM019		2	2		0
1		MSR237		2	2		0
1		MSR265		2	2		0
1		MSR051		5	2		0
2		ASM009		2	2		0
2		ASM028		2	2		0
1		MSR151		2	2		0
1		MSR017		2	2		0
1		MSR286		25	25		0
Posted
Updated 30-Mar-15 1:54am
v2

1 solution

Below query returns the highest value of dcr and leave fields.
SQL
SELECT [type], MAX(dcr) AS MaxOfDcr, MAX(leave) AS MaxOfLeave
FROM TableName
GROUP BY [type]


If you want to get something else, please let me know.

[EDIT]
SQL
SELECT MAX(CountOfDcr) AS MaxCountOfDcr, MAX(CountOfLeave) AS MaxCountOfLeave
FROM(
    SELECT dcr, COUNT(dcr) AS CountOfDcr, leave, COUNT(leave) AS CountOfLeave
    FROM TableName
    GROUP BY dcr, leave
) AS T


[/EDIT]
 
Share this answer
 
v4
Comments
Member 11337367 30-Mar-15 8:15am    
Ya,I need something else that which is maximum time repeated values in column cr,leave columns
Maciej Los 30-Mar-15 8:19am    
See updated answer ;)
Member 11337367 30-Mar-15 8:31am    
It will give only count of max number of times repeated vales..I want value of that
Maciej Los 30-Mar-15 8:40am    
Well, use subquery only.
Member 11337367 30-Mar-15 8:42am    
Can you show me how to write down..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900