Ò»µÀSqlÃæÊÔÌâÇó½â
Êý¾Ý¿â ÏÖÔÚÓбí1£¬±í2ÈçÏ£¬ÒªÇóÊä³ö±í3µÄÑù×Ó
Table1
yue dep yj
Ò»ÔÂ 1 10
¶þÔÂ 1 20
ÈýÔÂ 2 30
Table2
dep dep_name
1 ²¿ÃÅ1
2 ²¿ÃÅ2
3 ²¿ÃÅ3
4 ²¿ÃÅ4
Table3
dep Ò»ÔÂ ¶þÔÂ ÈýÔÂ
1
Table3
dep Ò»ÔÂ ¶þÔÂ ÈýÔÂ
1 10 20 null
2 null null 30
3 null null null
4 null null null
ÐÐתÁÐ
ÐÐתÁмÓÁ¬½Ó±í
SQL code:
if object_id('tb1')is not null drop table tb1
go
create table tb1(yue varchar(10), dep int, yj int)
insert tb1 select
'Ò»ÔÂ' , 1, 10 union all select
'¶þÔÂ', 1 , 20 union all select
'ÈýÔÂ' , 2 , 30
if object_id('tb2')is not null drop table tb2
go
create table tb2( dep int, dep_name varchar(10))
insert tb2 select
1, '²¿ÃÅ1' union all select
2, '²¿ÃÅ2'union all select
3, '²¿ÃÅ3' union all select
4, '²¿ÃÅ4'
select b.dep,
[Ò»ÔÂ]=max
Ïà¹ØÎÊ´ð£º
....½Óµ½Ò»¸öС³ÌÐò..¹¤×÷ÔÀ´´ó¸ÅÊÇÕâÑùµÄ...ǰ̨ÊÇWEB·þÎñÆ÷.¼Ü¹¹¾ÍÊÇASP+SQL..ǰ̨ÓÉASPÏòSQLÌí¼Ó·þÎñÀà±ð(±íµ¥).È»ºóÓÖºǫ́³ÌÐò¶ÁÈ¡±íµ¥..Ҫʵʱ¶ÁÈ¡..È»ºóÏÔʾÔÚ·þÎñÆ÷ÉÏÃæ..´ÓÀíÂÛÉÏÃæÄÜÐÐͨ²»?Èç¹û¿ÉÒÔ..ºǫ́ ......
´ó¼ÒºÃ£¬ÇëÎÊÔÚ±íMÖÐÓÐ×ֶΣºa b c d e
ÎÒÏë²é³öÆäÖÐÂú×ãÏÂÃæÈÎÒâÒ»ÏîµÄÊý¾Ý£¬1.×Ö¶Îa µÄÖµ²»ÊÇ ¡®Êé»ò±Ê»ò±¾¡¯ÖÐÈÎÒ»£¬2.aΪÊéµÄʱºò×Ö¶Îb,cÊÇ¿Õ;3.µ±aֵΪ±ÊµÄʱºòdÊÇ¿Õ;4.µ±aΪ±¾µÄʱºòb,d,e¶¼ÊÇ¿Õ;5.È ......
with adod_dict do
begin
close;
commandtext:='select bgqxcode,count(*) wjsl from wscl_wsda_file where wjnd=:tnd group by bgqxcode'; ......