Если все именно так, как ввы напсиали (т.е. во второй таблице есть поля Вася и Петя, а не Name), то запрос будет таким:</P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none <SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New' mso-ansi-language: EN-US; mso-no-proof: yes SELECT</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New' mso-ansi-language: EN-US; mso-no-proof: yes <FONT color=#000000> <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com

ffice

ffice" /><o

></o

></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none <SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New' mso-ansi-language: EN-US; mso-no-proof: yes <FONT color=#000000><SPAN style="mso-tab-count: 1 </SPAN>DateT<SPAN style="COLOR: gray ,</SPAN><FONT color=#000000> <o

></o

></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none <SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New' mso-ansi-language: EN-US; mso-no-proof: yes <SPAN style="mso-tab-count: 1 <FONT color=#000000> </SPAN><SPAN style="COLOR: fuchsia sum</SPAN><SPAN style="COLOR: gray (</SPAN><SPAN style="COLOR: blue case</SPAN><FONT color=#000000> <SPAN style="COLOR: blue when</SPAN><SPAN style="mso-spacerun: yes <FONT color=#000000> </SPAN><SPAN style="COLOR: red 'Вася'</SPAN><FONT color=#000000> <SPAN style="COLOR: blue then</SPAN><FONT color=#000000> cnt <SPAN style="COLOR: blue else</SPAN><FONT color=#000000> 0 <SPAN style="COLOR: blue end</SPAN><SPAN style="COLOR: gray )</SPAN><FONT color=#000000> Вася<SPAN style="COLOR: gray ,</SPAN><FONT color=#000000> <o

></o

></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none <SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New' mso-ansi-language: EN-US; mso-no-proof: yes <SPAN style="mso-tab-count: 1 <FONT color=#000000> </SPAN><SPAN style="COLOR: fuchsia sum</SPAN><SPAN style="COLOR: gray (</SPAN><SPAN style="COLOR: blue case</SPAN><FONT color=#000000> <SPAN style="COLOR: blue when</SPAN><SPAN style="mso-spacerun: yes <FONT color=#000000> </SPAN><SPAN style="COLOR: red 'Петя'</SPAN><FONT color=#000000> <SPAN style="COLOR: blue then</SPAN><FONT color=#000000> cnt <SPAN style="COLOR: blue else</SPAN><FONT color=#000000> 0 <SPAN style="COLOR: blue end</SPAN><SPAN style="COLOR: gray )</SPAN><FONT color=#000000> Петя<SPAN style="COLOR: gray ,</SPAN><FONT color=#000000> <o

></o

></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none <SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New' mso-ansi-language: EN-US; mso-no-proof: yes <o

><FONT color=#000000> </o

></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none <SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New' mso-ansi-language: EN-US; mso-no-proof: yes FROM</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New' mso-ansi-language: EN-US; mso-no-proof: yes <FONT color=#000000> Tbl <o

></o

></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none <SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New' mso-ansi-language: EN-US; mso-no-proof: yes GROUP</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New' mso-ansi-language: EN-US; mso-no-proof: yes <FONT color=#000000> <SPAN