一、SPC查询 根据日期查询

      应用到了随机函数

     NEWID()可以随机生成一个列值实现随机抓取记录

  CONVERT(varchar(100),列名, 23) AS TestDate  转换为日期格式 2013-14-14
  CONVERT(varchar(100),列名, 24) AS TestTime  转换为时间格式 19:24:25
 

   

     //SPC管制图 ExfoData

//SPC 管制图_ExfoData

SELECT TOP (5) Wave, Il_A, Refl_A, Il_B, Refl_B, TestDate, Time, Random
FROM (SELECT (CASE WHEN TWaveLength.Wvl_Id = 1 THEN '1310nm' WHEN TWaveLength.Wvl_Id
= 2 THEN '1550nm' WHEN TWaveLength.Wvl_Id = 3 THEN '850nm' WHEN TWaveLength.Wvl_Id
= 4 THEN '1300nm' END) AS Wave, TFiberMeasurement.Fim_ILEndA AS Il_A,
TFiberMeasurement.Fim_ReflectanceEndA AS Refl_A,
TFiberMeasurement.Fim_ILEndB AS Il_B,
TFiberMeasurement.Fim_ReflectanceEndB AS Refl_B, CONVERT(varchar(100),
TDUTMeasurement.Dum_MeasurementDate, 23) AS TestDate,
CONVERT(varchar(100), TDUTMeasurement.Dum_MeasurementDate, 24)
AS Time, NEWID() AS Random
FROM TTestTemplate INNER JOIN
TDUTMeasurement ON
TTestTemplate.Tst_Id = TDUTMeasurement.Dum_Tst_Id LEFT OUTER JOIN
TFiber INNER JOIN
TFiberMeasurement ON TFiber.Fib_Id = TFiberMeasurement.Fim_Fib_Id ON
TDUTMeasurement.Dum_Id = TFiberMeasurement.Fim_Dum_Id LEFT OUTER JOIN
TWaveLength ON TWaveLength.Wvl_Id = TFiberMeasurement.Fim_Wvl_Id)
AS derivedtbl_1
WHERE (TestDate > '2014-01-06') AND (TestDate < '2014-03-06')
ORDER BY Random

  //SPC管制图 3D_Data

 

//SPC管制图 3D_Data

SELECT TOP (100) (CASE LEFT(Type, 3) WHEN 'APC' THEN 'APC' ELSE 'PC' END) AS Type,
Result, Curvature, Spherical, Apex_Offset, Tilt_Angle, CONVERT(varchar(100),
Test_Date, 23) AS Test_Date, Test_Time, NEWID() AS Random
FROM User_3D_Test_Good
WHERE (Test_Date = '2013-12-05') AND ((CASE LEFT(Type, 3)
WHEN 'APC' THEN 'APC' ELSE 'PC' END) = 'PC')
ORDER BY Random

MY_SQLCode的更多相关文章

随机推荐

  1. centos7.0下删除yum和python之后恢复的办法

    centos 7如果卸载了yum和python之后恢复的办法(该方法已经测试). 下载 地址 http://mirrors.163.com/centos/7/os/x86_64/Packages/ 下 ...

  2. test_bdc

    [转]REPORT zbdc_test_by_shir. * 定义个BDC格式的内表**************************************************DATA : B ...

  3. [原创]java WEB学习笔记42:带标签体的自定义标签,带父标签的自定义标签,el中自定义函数,自定义标签的小结

    本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...

  4. UVA 1664 Conquer a New Region (并查集+贪心)

    并查集的一道比较考想法的题 题意:给你n个点,接着给你n-1条边形成一颗生成树,每条边都有一个权值.求的是以一个点作为特殊点,并求出从此点出发到其他每个点的条件边权的总和最大,条件边权就是:起点到终点 ...

  5. Function Pointers in C

    来源:https://cs.nyu.edu/courses/spring12/CSCI-GA.3033-014/Assignment1/function_pointers.html Function ...

  6. Codeforces 505C Mr. Kitayuta, the Treasure Hunter:dp【考虑可用范围】

    题目链接:http://codeforces.com/problemset/problem/505/C 题意: 有n个宝石,分别在位置p[i].(1 <= n,p[i] <= 30000) ...

  7. 分享知识-快乐自己:Shrio 案例Demo概述

    Shiro 权限认证核心: POM:文件: <!--shiro-all--> <dependency> <groupId>org.apache.shiro</ ...

  8. poj 1080 Human Gene Functions(lcs,较难)

    Human Gene Functions Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19573   Accepted:  ...

  9. openlayers 3加载GeoServer发布的wfs类型服务

    转:https://blog.csdn.net/u013323965/article/details/52449502 问题产生:      openlayer3加载WFS存在跨域问题,需要用json ...

  10. MySQL--Basic(一)

    停止与启动服务命令: net stop mysql net start mysql 修改MySQL提示符: mysql>prompt \u@\h \d> MySQL语句规范: 关键字与函数 ...