本文介绍了如何在sql server中获取具有group by的multipule列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果可能,请提供帮助。

Please need help if possible.

select  a.* from (
select  u.user_guid,u.user_name,u.user_email,u.user_type,
uinf.user_info_fname,uinf.user_info_lname,uinf.user_info_address,img.image_type,img.image_location,
v.visitor_datetime,v.visitor_duration,v.visitor_ip,v.media_guid
from

tb_visitors_log as v 
left outer join tb_media as m on v.media_guid=m.media_guid left outer join 
tb_users as u on v.user_guid=u.user_guid left outer join
tb_user_info as uinf on uinf.user_guid=u.user_guid
left outer join tb_images as img on img.image_guid=uinf.user_info_thumbnail

where v.media_guid=@media_guid and uinf.user_info_lname like concat('%',@searchvalue,'%')) as a
order by a.visitor_datetime desc



我希望输出按a.user_guid分组。在MySQL中我这样做:


I want the output to be grouped by a.user_guid. In MySQL I do this:

select a.* from (select u.user_guid,u.user_name,u.user_email,u.user_type,
uinf.user_info_fname,uinf.user_info_lname,uinf.user_info_address,img.image_type,img.image_location,
v.visitor_datetime,v.visitor_duration,v.visitor_ip,v.media_guid
from
tb_visitors_log as v 
left outer join tb_media as m on v.media_guid=m.media_guid left outer join 
tb_users as u on v.user_guid=u.user_guid left outer join
tb_user_info as uinf on uinf.user_guid=u.user_guid
left outer join tb_images as img on img.image_guid=uinf.user_info_thumbnail

where v.media_guid=P_media_guid and uinf.user_info_lname like concat('%',P_searchvalue,'%')
order by v.visitor_datetime desc
) as a group by a.user_guid;



但在SQL Server 2012中不能那样做













这是我的结果

https://plus.google.com/u/1/photos/104984108592274133808/albums/6044709663274953441/6044709665297999426?pid=6044709665297999426& oid = 104984108592274133808





这是我想要的那个

https:// plus。 google.com/u/1/photos/104984108592274133808/albums/6044709663274953441/6044709666972693378?pid=6044709666972693378&oid=104984108592274133808


But in SQL Server 2012 I can't do that






this my resultt
https://plus.google.com/u/1/photos/104984108592274133808/albums/6044709663274953441/6044709665297999426?pid=6044709665297999426&oid=104984108592274133808


and this is the one i want to have
https://plus.google.com/u/1/photos/104984108592274133808/albums/6044709663274953441/6044709666972693378?pid=6044709666972693378&oid=104984108592274133808

推荐答案

这篇关于如何在sql server中获取具有group by的multipule列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 17:46