Maximu value along with all fields value

imfarhan

Board Regular
Joined
Jan 29, 2010
Messages
125
Office Version
  1. 2016
Platform
  1. Windows
<TABLE cellSpacing=0 bgColor=#ffffff border=1><CAPTION>qryMax No of procedures</CAPTION><THEAD><TR><TH borderColor=#000000 bgColor=#c0c0c0>InternalNo</TH><TH borderColor=#000000 bgColor=#c0c0c0>EpisodeNo</TH><TH borderColor=#000000 bgColor=#c0c0c0>All_Proc</TH><TH borderColor=#000000 bgColor=#c0c0c0>CntProcedures</TH></TR></THEAD><TBODY><TR vAlign=top><TD borderColor=#c0c0c0>1234</TD><TD borderColor=#c0c0c0>7</TD><TD borderColor=#c0c0c0>W90.1 Z84.6 Z94.2</TD><TD borderColor=#c0c0c0 align=right>3</TD></TR><TR vAlign=top><TD borderColor=#c0c0c0>1235</TD><TD borderColor=#c0c0c0>1</TD><TD borderColor=#c0c0c0>B37.1 Z94.2</TD><TD borderColor=#c0c0c0 align=right>2</TD></TR><TR vAlign=top><TD borderColor=#c0c0c0>1236</TD><TD borderColor=#c0c0c0>5</TD><TD borderColor=#c0c0c0>W36.3 W36.5 Z75.3</TD><TD borderColor=#c0c0c0 align=right>3</TD></TR><TR vAlign=top><TD borderColor=#c0c0c0>1236</TD><TD borderColor=#c0c0c0>1</TD><TD borderColor=#c0c0c0>G45.9</TD><TD borderColor=#c0c0c0 align=right>1</TD></TR><TR vAlign=top><TD borderColor=#c0c0c0>1234</TD><TD borderColor=#c0c0c0>13</TD><TD borderColor=#c0c0c0>S06.9 Z50.4 Z94.3 Z50.1 Z94.2</TD><TD borderColor=#c0c0c0 align=right>5</TD></TR></TBODY><TFOOT></TFOOT></TABLE>

Hi I would like to pull only that row which keep maximum cntprocedure along with all fields.
I have tried following queries but no success

Select internalNo,EpisodeNo, All_proc,Max(CntProcedures)
from table
group by internalNo,EpisodeNo, All_proc

It pulls all rows with their grroup but I want pull only following row in this case?

<TABLE cellSpacing=0 bgColor=#ffffff border=1><TBODY><TR vAlign=top><TD borderColor=#c0c0c0>1234</TD><TD borderColor=#c0c0c0>13</TD><TD borderColor=#c0c0c0>S06.9 Z50.4 Z94.3 Z50.1 Z94.2</TD><TD borderColor=#c0c0c0 align=right>5</TD></TR></TBODY><TFOOT></TFOOT></TABLE>

Also tried but generate error
Select internalNo,EpisodeNo, All_proc, cntprocdeure
from table a
where exists (select max(cntprocdure) from table b
where a.internalno = b.internalno)

Thanks for your help

regards
F

 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Here you go - change the table name of TableProcs to the name of your query which gives you the initial counts.
Code:
SELECT TableProcs.InternalNo, TableProcs.EpisodeNo, TableProcs.All_Proc, TableProcs.CntProcedures
FROM TableProcs
WHERE (((TableProcs.CntProcedures)=(Select Max([CntProcedures]) From TableProcs)));
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top