不确定如何进行此查询。不知道该怎么称呼这种类型的查询,请更正此标题!

发布于 2024-11-25 23:17:25 字数 1081 浏览 2 评论 0原文

该查询应该使用 SQL 与 ms access 2003 一起运行。不明确支持 JOIN 函数。隐含在 WHERE 子句中是可以的...只要不使用 JOIN INNER JOIN 等单词,任何地方的隐含都可以。

     DayNumnber   PastTime
               .
               .
               .

       333           Homework
       333           TV
       334           Date
       620           Chores
       620           Date
       620           Homework
       725           Chores
       725           Date
       888           Internet
       888           TV
                  .
                  .
                  .

嘿,我想要一个查询,可以显示每天完成的最重要的过去时间(电视和互联网不算!)。所以重要性是家庭作业>家务事> Date.So:

       DayNumber     PastTime
         333           Homework
         334           Date
         620           Homework
         725           Chores

可能会改变这个问题的东西。尽管所有不同的过去时光都在一张桌子上一起聆听。但那是因为我附加了表格。最初是作业条目。杂务条目和日期条目。互联网条目。电视条目。来自不同的桌子。

 eg     homework 333
        homework 620

如果不先附加这些表格,是否会更容易做到这一点?我希望它能用附加的表格来完成,但是

我正在考虑插入的混合。删除...但最困难的部分是检查是否有一些适合日期的事情以及如何在当天完成更重要的事情。谢谢

This query is supposed to run with ms access 2003 using SQL. the function JOIN is NOT supported explicitly. implicitly in the WHERE clause is fine...implicity anywhere is fine as long as the word JOIN INNER JOIN Etc is not used.

     DayNumnber   PastTime
               .
               .
               .

       333           Homework
       333           TV
       334           Date
       620           Chores
       620           Date
       620           Homework
       725           Chores
       725           Date
       888           Internet
       888           TV
                  .
                  .
                  .

Hey I would like a query that can Show the most important past time done for each day (TV and internet do not count!) .So importance would be Homework > Chores > Date.So:

       DayNumber     PastTime
         333           Homework
         334           Date
         620           Homework
         725           Chores

Something that might change this problem. Altho all the different past times are listen in a table together. but that was because i appended the table. originally the homework entries. chore entries and date entriess . internet entriess. tv entries. came from different tables.

 eg     homework 333
        homework 620

Is it easier to do it without appending these tables first? I would hopefully like it to be done with the appended table but ya

I was thinking of a mixture of insert. delete... but the hardest part is checking that there is something there for a date a few things and how to put the more important thing done that day . Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

堇年纸鸢 2024-12-02 23:17:26

创建另一个表:

Pri | PastTime
--------------
  1 | Homework
  2 | Chores
  3 | Date

这是项目的优先级列表。

下一步:

  SELECT MIN(Pri), DayNumber
    FROM PastTime_table, Priority_table
   WHERE PastTime_table.PastTime = Priority_table.PastTime
GROUP BY DayNumber

这将为您提供每天最重要的过去时间。由于电视和互联网未列出,因此它们不会出现。

但它会给你一个号码,而不是名字。

如果您有更好的 SQL,则可以将其连接回 Priority_table 并查找名称。但我想你必须手动完成该部分。

如果您愿意更改名称并称呼他们:

A_Homework
B_Chores
C_Date

相反,您可以这样做(无需任何额外的表格):

  SELECT MIN(PastTime), DayNumber
    FROM PastTime_table
GROUP BY DayNumber

因为它按字母顺序对名称进行排序,所以它总是会给您最好的名称。

您可以添加 WHERE 来删除电视和互联网。

Create another table with:

Pri | PastTime
--------------
  1 | Homework
  2 | Chores
  3 | Date

This is a priority list for the items.

Next do:

  SELECT MIN(Pri), DayNumber
    FROM PastTime_table, Priority_table
   WHERE PastTime_table.PastTime = Priority_table.PastTime
GROUP BY DayNumber

This will give you the most important past time for each day. And because TV and Internet are not listed they will not show up.

But it will give you a number, and not the name.

If you had a better SQL you could then join this back to the Priority_table and lookup the name. But I guess you will have to do that part manually.

If you are willing to change the name and call them:

A_Homework
B_Chores
C_Date

instead then you could do (without any extra table):

  SELECT MIN(PastTime), DayNumber
    FROM PastTime_table
GROUP BY DayNumber

Since it sorts the name alphabetically it will always give you the best one.

You can add a WHERE to remove TV and Internet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文