zoukankan      html  css  js  c++  java
  • 先聚合再连接

    string SQL = @"select isnull(i.IntegralSum,0.0)as IntegralSum,a.AccountSum,u.UserLave,u.AddTime from Bst_User u 

    left join  (select UserId,sum(cast(IntegralCount as numeric(10,2))) as IntegralSum 

    from Bst_Integral where IsOver=0 group by UserId) i 

    on i.UserId=u.UserId 

    inner join (select UserId,sum(cast(YourCount as numeric(10,2))) as AccountSum from Bst_UserAccount group by UserId) a

    on a.UserId=u.UserId where u.UserName='"+ Session["User"].ToString() + "'";

    string SQL = @"

    select * from (select top 1 Id, Title,ArtPic from

    (

    select top 1 Id, Title,ArtPic from  Ec_Art where IsCheck=1  and  ArtPic<>'' and IsTop=1 and  NodeId=25

    union 

    select  0,'暂无新闻','images/tp.gif' 

    )aa  order by Id desc

    union all 

    select top 1 Id, Title,ArtPic from 

    (

    select top 1  Id, Title,ArtPic from  Ec_Art where IsCheck=1  and  ArtPic<>'' and IsTop=1 and  NodeId=28

    union all 

    select  0,'暂无新闻','images/tp.gif' 

    )bb  order by Id desc

    union all 

    select top 1 Id, Title,ArtPic from 

    (

    select top 1  Id, Title,ArtPic from  Ec_Art where IsCheck=1  and  ArtPic<>'' and IsTop=1 and  NodeId=30

    union all 

    select  0,'暂无新闻','images/tp.gif' 

    )cc  order by Id desc

    union all 

    select top 1 Id, Title,ArtPic from 

    (

    select top 1  Id, Title,ArtPic from  Ec_Art where IsCheck=1  and  ArtPic<>'' and IsTop=1 and  NodeId=36

    union all 

    select  0,'暂无新闻','images/tp.gif' 

    )dd  order by Id desc

    union all 

    select top 1 Id, Title,ArtPic from 

    (

    select top 1  Id, Title,ArtPic from  Ec_Art where IsCheck=1  and  ArtPic<>'' and IsTop=1 and  NodeId=38

    union all 

    select  0,'暂无新闻','images/tp.gif' 

    )ee  order by Id desc

    union all 

    select top 1 Id, Title,ArtPic from 

    (

    select top 1  Id, Title,ArtPic from  Ec_Art where IsCheck=1  and  ArtPic<>'' and IsTop=1 and  NodeId=42

    union all 

    select  0,'暂无新闻','images/tp.gif' 

    )ff  order by Id desc

    union all 

    select top 1 Id, Title,ArtPic from 

    (

    select top 1  Id, Title,ArtPic from  Ec_Art where IsCheck=1  and  ArtPic<>'' and IsTop=1 and  NodeId=34

    union all 

    select  0,'暂无新闻','images/tp.gif' 

    )gg  order by Id desc

    union all 

    select top 1 Id, Title,ArtPic from 

    (

    select top 1  Id, Title,ArtPic from  Ec_Art where IsCheck=1  and  ArtPic<>'' and IsTop=1 and  NodeId=31

    union all 

    select  0,'暂无新闻','images/tp.gif' 

    )hh  order by Id desc)

    ddd";

  • 相关阅读:
    Asp.Net MVC3 简单入门第一季(五) 通过Asp.Net MVC的区域功能实现将多个MVC项目部署到一个站点
    Asp.Net MVC3 简单入门第一季(一)环境准备
    Asp.Net MVC3 简单入门第一季(三)详解Controller之Filter
    Entity Framework快速入门一对零到一关系处理
    Html5 学习系列(一)认识HTML5
    程序员体检完事后的感受
    Asp.Net MVC3 简单入门第一季 【索引贴】
    实在忍不住,【转】一篇好文章!题目:【转】想要成功,请记住!
    Html5 学习系列(二)HTML5新增结构标签
    大学应该怎么读?
  • 原文地址:https://www.cnblogs.com/jshchg/p/1753306.html
Copyright © 2011-2022 走看看