SQL查询,过去一年访问过​​的人

时间:2016-04-18 06:57:27

标签: sql oracle create-table

我遇到SQL查询问题。特别是这个,就像这样。

我有2张桌子,病人和探访。

CREATE TABLE patients (
   ID_patients INTEGER NOT NULL,
   Name VARCHAR NOT NULL
);

CREATE TABLE visit(
    ID_visit INTEGER NOT NULL,
    DATE_visit DATE NOT NULL,
    FK_patients INTEGER NOT NULL
);

现在我想询问一下,这会告诉我过去一年中访问过哪些病人?而且我在2015年并不意味着,但在BETWEN(今天 - 365天)和(今天 - 730天)之间。我希望有人可以给我一些有用的提示。

2 个答案:

答案 0 :(得分:0)

select * from visit
where DATE_visit between
CURRENT_DATE - interval 2 year and CURRENT_DATE - interval 1 year;

答案 1 :(得分:0)

尝试此操作以获取所有<!DOCTYPE html> <html> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <body> <div ng-app="Calc" ng-controller="Calc_Ctrl"> <script src="newscript.js"></script> <div class = "col-lg-8 col-md-7 col-sm-7 col-xs-12 center-output " ng-app="Calc" ng-controller="Calc_Ctrl" > <div class="col-md-3 col-sm-5 col-xs-5"> <div class="form-group"> <h6>type </h6> <select class="form-control" id="category" ng-model="selectedcategory" ng-options="y.typeOfWork for (x, y) in type.ceramicAndVetrified" ng-change="GetSelectedCategary()"> </select> <span class="arrow"></span> </div> </div> <div class="col-md-3 col-sm-5 col-xs-5"> <div class="form-group"> <h6> Material </h6> <select class="form-control" id="sel2" ng-disabled="!selectedcategory" ng-model="selectedtype" ng-options="y.activity for (x, y) in selectedcategory" ng-change="GetSelectedType()"> </select> </div> </div> <div class="col-md-3 col-sm-5 col-xs-5"> <div class="form-group"> <h6>Size: </h6> <select class="form-control" id="sel3" ng-disabled="!selectedtype" ng-model="selectedsize" ng-options="y.tileDimension for (x, y) in selectedtype.tileSizes"> </select> <span class="arrow"></span> </div> </div> </div> </div> </html> </body>名称:

patients