我正在尝试创建一个自动执行的Pervasive SQL(PSQL)视图命令,该命令可以在运行中抢先删除表中的重复行。创建单列表视图的基本命令如下:
CREATE VIEW "VIEW_EMP" AS SELECT "ATTENDANCE" . "EMPLOYEE" FROM "TIME_ATTENDANCE"
我想知道是否有人有任何想法如何实施避免重复追加EMPLOYEE字段的方法?如您所见,源表的名称是ATTENDANCE,目标表(视图)的名称将是VIEW_EMP。
我发现PSQL与MySQL非常相似,所以即使你不知道PSQL,也许你仍然可以回答这个问题。我发现使用MySQL DELETE命令发布this帖子,但我不知道它是否适用于我的特定情况。
答案 0 :(得分:1)
在大多数SQL版本中,您将使用
@using Arpon.Web.Loader.Utils.Helpers;
@model ICollection<Arpon.Web.Brain.Pos.Models.Pos>
@ViewBag.key1
<script>
onDocExtendedLoad(
function run() {
var PdvId = document.getElementById("pdvlist").value;
$('select[name=pdvlist]').change(function () { alert($(this).val()); });
}
);
</script>
<div class="page-title">
<i class="fa fa-bar-chart-o"></i>
<h3>POS</h3>
</div>
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-12 sortable">
<div class="grid simple vertical green">
<div class="grid-title no-border">
<h4>@this.FP("Punto de Venta")</h4>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
<a href="javascript:;" class="reload"></a>
</div>
</div>
<div class="grid-body no-border">
<div class="p-l-20 p-r-20 p-b-10 p-t-10 b-b b-grey">
<div class="row">
<div class="col-md-4">
<div class="form-group">
<h5 class="bold pull-left m-r-5">@this.FP("lbl.loader.date")</h5>
<div class="controls">
<div class="input-append success no-padding">
<div id="reportrange" class="pull-right div-daterangepicker">
<i class="fa fa-calendar fa-lg"></i>
<span>@date.ToString("d MMMM, yyyy") - @date.ToString("d MMMM, yyyy")</span> <b class="caret"></b>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<h5 class="bold pull-left m-r-5">@this.FP("Restaurante")</h5>
<div class="controls">
<div class="input-append success no-padding">
<select class="ctl-source">
<option value="">Todos</option>
<option value="DE">Desayuno</option>
<option value="CO">Comida</option>
<option value="CE">Cena</option>
</select>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<h5 class="bold pull-left m-r-5">@this.FP("PDV")</h5>
<div class="controls">
<div class="input-append success no-padding">
@using (Html.BeginForm())
{
<select id="pdvlist" name="pdvlist" class="ctl-source" onchange="run()">
<option value=" ">Todos</option>
@foreach (var item in Model.Select(l => l.Pdv).Distinct())
{
<option value="@item">@item</option>
}
</select>
<input type="submit" value="Actualizar" />
}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row" id="dateWidgetIncomeBanquetPanel">
<table class="table table-hover no-more-tables table-iconmebanquet-detail">
<thead>
<tr>
<th style="">Platillo</th>
<th style="">PV</th>
<th style="">1</th>
<th style="">2</th>
<th style="">3</th>
<th style="">4</th>
<th style="">5</th>
<th style="">6</th>
<th style="">7</th>
<th style="">8</th>
<th style="">9</th>
<th style="">10</th>
<th style="">11</th>
<th style="">12</th>
<th style="">13</th>
<th style="">14</th>
<th style="">15</th>
<th style="">16</th>
<th style="">17</th>
<th style="">18</th>
<th style="">19</th>
<th style="">20</th>
<th style="">21</th>
<th style="">22</th>
<th style="">23</th>
<th style="">24</th>
<th style="">25</th>
<th style="">26</th>
<th style="">27</th>
<th style="">28</th>
<th>Total</th>
<th>Venta</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
var total = 0;
decimal costo = 0;
for (int i = 1; i <= 28; i++)
{
var value = 0;
if (item.Fecha.Day == i) { value = item.Cantidad; costo = costo + item.Total; }
total += value;
}
<tr>
<td>@item.Descripcion</td>
<td>@((costo / total).ToString("C"))</td>
@for (int i = 1; i <= 28; i++)
{
var value = 0;
int month = item.Fecha.Month;
if (item.Fecha.Day == i) { value = item.Cantidad; }
<td>
<a href="javascript:void(0)" data-toggle="popover"
data-html="true" data-original-title="@i/@month/2015" data-placement="bottom" data-content="Producto: @item.Descripcion<br />PV:@((costo / total).ToString("C"))<br />Total:@value<br />Venta:@(((costo / total) * value).ToString("C"))" data-trigger="hover">@value</a>
</td>
}
<td>@total</td>
<td>@(((costo / total) * total).ToString("C"))</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
或
SELECT DISTINCT ATTENDANCE.EMPLOYEE
FROM TIME_ATTENDANCE
你尝试过其中一种吗?