--普通标、定向标、新手标、老互融计划-投资记录表
select bid.borrow_id,
(select yyb.borrow_valid_time from YYD_Borrow_BorrowInfo as yyb where yyb.ID=bid.borrow_id ) as borrow_valid_time,
(select yyb.borrow_end_time from YYD_Borrow_BorrowInfo as yyb where yyb.ID=bid.borrow_id ) as borrow_end_time,
(select yyb.BidComRate from YYD_Borrow_BorrowInfo as yyb where yyb.ID=bid.borrow_id ) as BidComRate,
(select yyb.Title from YYD_Borrow_BorrowInfo as yyb where yyb.ID=bid.borrow_id ) as Title,
bid.amount as amount,
(select yyb.BorrowCode from YYD_Borrow_BorrowInfo as yyb where yyb.ID=bid.borrow_id) as BorrowCode,
(select yyb.borrow_period from YYD_Borrow_BorrowInfo as yyb where yyb.ID=bid.borrow_id) as borrow_period,
(select yyb.status from YYD_Borrow_BorrowInfo as yyb where yyb.ID=bid.borrow_id) as statuss,
bid.createtime as createtime,
--(select DATEADD(MONTH,yyb.borrow_period,yyb.loanDate) from YYD_Borrow_BorrowInfo as yyb where yyb.ID=bid.borrow_id ) as endDate
(
select case when yyb.loanDate='1900-01-01 00:00:00.000' then '1900-01-01 00:00:00.000' else
DATEADD(MONTH,yyb.borrow_period,yyb.loanDate) end
from YYD_Borrow_BorrowInfo as yyb where yyb.ID=bid.borrow_id

) as endDate

from YYD_Borrow_BidRecord as bid inner join YYD_Borrow_borrowinfo_ext as ext on bid.borrow_id = ext.borrow_id where ext.borrow_product<>50 and ext.borrow_product<>70 and bid.bid_user_id=1239

union all

--新互融计划投资记录表
select newbid.nplid,'' as borrow_valid_time,'' as borrow_end_time,'' as BidComRate,
(select bTitle+'['+qishu+']' from HUR_NewPlanLoan where id=newbid.nplid)Title,
newbid.amount as amount,'' as BorrowCode,
(select bPeriod from HUR_NewPlanLoan where id=newbid.nplid)borrow_period,
newbid.nplStatus as statuss,newbid.createtime as createtime,

(select case when yyb.loanDate='1900-01-01 00:00:00.000' then '1900-01-01 00:00:00.000' else
DATEADD(MONTH,loan.bPeriod,yyb.loanDate) end from YYD_Borrow_BorrowInfo as yyb,HUR_NewPlanLoan as loan
where yyb.id in (select top 1 borrowId from HUR_NewPlanLoan_ItemLoan as item
where item.nplBid = newbid.id) and loan.id = newbid.nplid) as endDate
from HUR_NewPlanLoan_BidRecord as newbid where newbid.nplStatus=1 and newbid.userid=1337

union all

----个人债权转让的投资记录表
select bid.borrow_id,
(select yyb.borrow_valid_time from YYD_Borrow_BorrowInfo as yyb where yyb.ID=(
select top 1 ext.OrginBorrowId from YYD_Borrow_borrowinfo_ext as ext where ext.borrow_id=bid.borrow_id)) as borrow_valid_time,
(select yyb.borrow_end_time from YYD_Borrow_BorrowInfo as yyb where yyb.ID=(
select top 1 ext.OrginBorrowId from YYD_Borrow_borrowinfo_ext as ext where ext.borrow_id=bid.borrow_id)) as borrow_end_time,
(select yyb.BidComRate from YYD_Borrow_BorrowInfo as yyb where yyb.ID=(
select top 1 ext.OrginBorrowId from YYD_Borrow_borrowinfo_ext as ext where ext.borrow_id=bid.borrow_id)) as BidComRate,

(select yyb.Title from YYD_Borrow_BorrowInfo as yyb where yyb.id =(
select top 1 ext.OrginBorrowId from YYD_Borrow_borrowinfo_ext as ext where ext.borrow_id=bid.borrow_id)) as Title,

bid.amount as amount,

(select yyb.BorrowCode from YYD_Borrow_BorrowInfo as yyb where yyb.id =(
select top 1 ext.OrginBorrowId from YYD_Borrow_borrowinfo_ext as ext where ext.borrow_id=bid.borrow_id)) as BorrowCode,

(select yyb.borrow_period from YYD_Borrow_BorrowInfo as yyb where yyb.id =(
select top 1 ext.OrginBorrowId from YYD_Borrow_borrowinfo_ext as ext where ext.borrow_id=bid.borrow_id)) as borrow_period,

(select yyb.status from YYD_Borrow_BorrowInfo as yyb where yyb.id =(
select top 1 ext.OrginBorrowId from YYD_Borrow_borrowinfo_ext as ext where ext.borrow_id=bid.borrow_id)) as statuss,
bid.createtime as createtime,
--(select DATEADD(MONTH,yyb.borrow_period,yyb.loanDate) from YYD_Borrow_BorrowInfo as yyb where id =(
--select top 1 ext.OrginBorrowId from YYD_Borrow_borrowinfo_ext as ext where ext.borrow_id=bid.borrow_id)) as endDate
(select case when yyb.loanDate='1900-01-01 00:00:00.000' then '1900-01-01 00:00:00.000' else
DATEADD(MONTH,yyb.borrow_period,yyb.loanDate) end
from YYD_Borrow_BorrowInfo as yyb where yyb.id =(select top 1 ext.OrginBorrowId from YYD_Borrow_borrowinfo_ext as ext
where ext.borrow_id=bid.borrow_id)) as endDate

from YYD_Borrow_BidRecord as bid inner join YYD_Borrow_borrowinfo_ext as ext on bid.borrow_id = ext.borrow_id
where ext.borrow_product=50 and bid.bid_user_id=1239

用户列表-投资记录sql的更多相关文章

  1. 使用mybatis提供的各种标签方法实现动态拼接Sql。这里演示where标签和if标签实现使用姓名的模糊查询和性别查询用户列表,当用户没有选择姓名以及性别时查询出所有的记录。

    1.需求: 使用姓名的模糊查询和性别查询用户列表,当用户没有选择姓名以及性别时查询出所有的记录. 2.在UserMapper接口中定义方法: public List<User> findU ...

  2. SQL练习题_用户购买收藏记录合并(拼多多)

    目录 拼多多笔试题0805_统计用户数据 笔试题描述 表格构建 数据观察 题目分析 一.合并表格 二.CASE表示(0,1) 三.同理复制FORK表 题目解答 拼多多笔试题0805_统计用户数据 笔试 ...

  3. sql -- 获取连续签到的用户列表

    签到表: 需求:统计连续签到的 用户 1.根据用户和日期分组 select user_name, sign_date from user_sign group by user_name, sign_d ...

  4. C#开发微信门户及应用(4)--关注用户列表及详细信息管理

    在上个月的对C#开发微信门户及应用做了介绍,写过了几篇的随笔进行分享,由于时间关系,间隔了一段时间没有继续写这个系列的博客了,并不是对这个方面停止了研究,而是继续深入探索这方面的技术,为了更好的应用起 ...

  5. 记录SQL Server2008日志文件损坏的恢复过程

    记录SQL Server2008日志文件损坏的恢复过程: 环境: 系 统:Windows Server2003 数据库:SQL Server2008 故障原因: 通过mstsc链接同一服务器时,用户界 ...

  6. 在MySQL中使用init-connect与binlog来实现用户操作追踪记录

    在MySQL中使用init-connect与binlog来实现用户操作追踪记录 分类: MySQL 前言: 测试环境莫名其妙有几条重要数据被删除了,由于在binlog里面只看到是公用账号删除的,无法查 ...

  7. Android 实现用户列表信息的功能,然后选择删除幻灯片删除功能

    在项目开发过程中.经常须要对用户列表的信息进行删除的操作.Android中经常使用的删除操作方式有两种 .一种就是类似微信的滑动出现删除button方式,另一种是通过CheckBox进行选择.然后通过 ...

  8. 基于Redis的在线用户列表解决方案

    前言: 由于项目需求,需要在集群环境下实现在线用户列表的功能,并依靠在线列表实现用户单一登陆(同一账户只能一处登陆)功能: 在单机环境下,在线列表的实现方案可以采用SessionListener来完成 ...

  9. [项目回顾]基于Redis的在线用户列表解决方案

    迁移:基于Redis的在线用户列表解决方案 前言: 由于项目需求,需要在集群环境下实现在线用户列表的功能,并依靠在线列表实现用户单一登陆(同一账户只能一处登陆)功能: 在单机环境下,在线列表的实现方案 ...

随机推荐

  1. [LED]如何配置LCD背光和LED,调试方法

    [DESCRIPTION] 如何配置LCD背光和LED,调试方法 [SOLUTION]LCD背光和LED配置文件alps/custom/<proj name>lk/cust_leds.ca ...

  2. Http状态总结

    常见的http状态总结: 如果向您的服务器发出了某项请求要求显示您网站上的某个网页,那么,您的服务器会返回 HTTP 状态代码以响应该请求.一些常见的状态代码为: 200 - 服务器成功返回网页 40 ...

  3. Android 热补丁动态修复框架小结

    一.概述 最新github上开源了很多热补丁动态修复框架,大致有: https://github.com/dodola/HotFix https://github.com/jasonross/Nuwa ...

  4. 深入浅出RxJava(一:基础篇)

    RxJava正在Android开发者中变的越来越流行.唯一的问题就是上手不容易,尤其是大部分人之前都是使用命令式编程语言.但是一旦你弄明白了,你就会发现RxJava真是太棒了. 这里仅仅是帮助你了解R ...

  5. excel 里面拼接 MySQL insert 语句

    ="('"&A2&"',"&" '"&B2&"','"&C2&& ...

  6. java集合和scala集合互转

    使用 scala.collection.JavaConverters 与Java集合交互.它有一系列的隐式转换,添加了asJava和asScala的转换方法.使用它们这些方法确保转换是显式的,有助于阅 ...

  7. DB2数据库中SQL语句中使用or和and的关键字的时候注意事项

    --正确的SQL语句,查询结果:746 ) FROM EHR_BASE EB, EHR_HF_INDICATOR EHI WHERE EB.EHR_ID=EHI.EHR_ID ' ' ' AND EB ...

  8. C# Socket编程(3)编码和解码

    在网络通信中,很多情况下:比如说QQ聊天,通讯双方直接传递的都是字符信息.但是字符信息并不能够直接通过网络传输,这些字符集必须先转换成一个字节序列后才能够在网络中传输,于是这里就产生了编码和解码的概念 ...

  9. nginx的启动与关闭

    [root@nginx ~]# #默认启动方式 [root@nginx ~]# which nginx /sbin/nginx [root@nginx ~]# nginx [root@nginx ~] ...

  10. dede 调用四级导航

    一.修改文件:\include\taglib目录下的channel.lib.php,请将以下代码全部复制替换上述文件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ...