要求:响应用户输入StartDate,EndDate和Upper Data Threshold,生成基于电话号码输出数据的查询。SQL MS Access查询的排除条件
这些输入变量是查询的边界。因此,SELECT语句被写在下面。
唯一需要注意的是,如果某个电话号码的单个记录超过了上限数据阈值,则与该违规电话号码关联的所有电话号码记录都不应输出,而不管该电话号码的其他记录是什么不违反数据阈值。下面是样本输入和预期输出:
Invc Date Mobile Nbr PktDtVol Difference in Days
--------- ---------- -------- -------------------
7/15/15 718-500-2311 3kB 304
8/15/15 718-500-2311 45kB 304
9/15/15 718-500-2311 25kB 304
10/15/15 514-300-3311 33kB 304
11/15/15 514-300-3311 20kB 304
我当前的解决方案:
PARAMETERS [Start Date] DateTime, [End Date] DateTime, [Upper Bound
Usage in KB] IEEEDouble;
SELECT [Master].[Invc Date], [Master].PktDtVol, [Master].[Mobile Nbr],
DateDiff("d",[Start Date],[End Date]) AS [Difference in days] INTO
Temp_Table
FROM [Master]
WHERE ((([Master].[Invc Date]) >= [Start Date] And
([Master].[Invc Date])<=[End Date]) AND
(([Master].PktDtVol)<= [Upper Bound Usage in KB]));
不期望的647-409-8206记录在[Temp_Table]
User input Start Date: 1/15/2015
User input End Date: 11/15/2015
User input Upper Data Threshold in kB: 50
[Master] Table in Access:
Invc Date Mobile Nbr PktDtVol
--------- ---------- --------
1/15/15 647-409-8206 48kB
2/15/15 647-409-8206 33kB
3/15/15 647-409-8206 8000kB
4/15/15 647-409-8206 20kB
5/15/15 647-409-8206 10kB
6/15/15 647-409-8206 0kB
7/15/15 718-500-2311 3kB
8/15/15 718-500-2311 45kB
9/15/15 718-500-2311 25kB
10/15/15 514-300-3311 33kB
11/15/15 514-300-3311 20kB
的预期输出在输出中,因为只有1条记录超过了50kB(第3条记录),所以所有的647-409-8206条记录都将被相应省略。
请欣赏任何帮助!谢谢!
那些看起来像真正的电话号码和搜索作为真正的电话号码。你确定你想和很多人分享吗? – Fionnuala
他们肯定是假的数字,我相应地修改了数据 - 但谢谢! – stitch70
您似乎也有一些设计错误。 – Fionnuala