--***** 查询至少有150天未登陆QQ账号的用户信息,包括QQ号码,最好一次登陆时间,等级,昵称,年龄,并按时间进行排序--
select * from BaseInfo s
inner join QQUser m on s.QQID=m.QQID
where DATEDIFF (DD ,m.lastLogTime,GETDATE())>=150
order by LastLogTime DESC
--查询QQ号为54789625的用户的好友信息每个省份的人数,并且按总人数从大到小--
select COUNT(*),m.Province from Relation s inner join BaseInfo m on s.RelationQQID=m.QQID
where(s.QQID=54789625) group by m.Province
select COUNT(m.Province),m.Province from Relation s,BaseInfo m where(s.QQID=54789625 and s.RelationStatus=0 and s.RelationQQID=m.QQID)
group by m.Province order by COUNT(m.Province) DESC