MS QUERY语法更正

时间:2012-12-11 17:35:22

标签: ms-query

目前我正在为我运行此查询

SELECT `Sheet1$`.ACCT_CODE, `Sheet1$`.ACCTG_DATE, `Sheet1$`.AGENT_NO, `Sheet1$`.BAL_BOOK_CODE, `Sheet1$`.JRNL_ID_NO, `Sheet1$`.PRODUCT_CODE, `Sheet1$`.SOURCE_SYSTEM_ID, `Sheet1$`.`SUM(DR_CR_AMOUNT)`
FROM `Sheet1$` `Sheet1$`
WHERE (`Sheet1$`.BAL_BOOK_CODE='5092') AND (`Sheet1$`.ACCT_CODE Not Like '%H%') AND (`Sheet1$`.AGENT_NO='943776') OR (`Sheet1$`.BAL_BOOK_CODE='509A') AND (`Sheet1$`.ACCT_CODE Not Like '%H%') AND (`Sheet1$`.AGENT_NO='943776')
ORDER BY `Sheet1$`.ACCT_CODE

查询的结果仅限于AGENT_NO ='943776'

我希望结果显示

  1. ACCT_CODE不喜欢'%H%'和
  2. 如果AGENT_NO ='943776',则BAL_BOOK_CODE ='509A'或BAL_BOOK_CODE ='5092'
  3. 显示所有其他AGENT_NO

1 个答案:

答案 0 :(得分:0)

SELECT Sheet1$。ACCTG_DATE,Sheet1$。JRNL_ID_NO,Sheet1$。ACCT_CODE,Sheet1$。SOURCE_SYSTEM_ID,Sheet1$。AGENT_NO,Sheet1$。 PRODUCT_CODE,Sheet1$。BAL_BOOK_CODE,Sheet1$SUM(DR_CR_AMOUNT) 来自C:\Documents and Settings\Amit Joshi\Desktop\Book1.xlsxSheet1$ Sheet1$ WHERE(Sheet1$。ACCT_CODE不喜欢' __ H ')AND(Sheet1$。AGENT_NO<>'943776')

全联盟

SELECT Sheet1$。ACCTG_DATE,Sheet1$。JRNL_ID_NO,Sheet1$。ACCT_CODE,Sheet1$。SOURCE_SYSTEM_ID,Sheet1$。AGENT_NO,Sheet1$。 PRODUCT_CODE,Sheet1$。BAL_BOOK_CODE,Sheet1$SUM(DR_CR_AMOUNT) 来自C:\Documents and Settings\Amit Joshi\Desktop\Book1.xlsxSheet1$ Sheet1$ WHERE(Sheet1$。BAL_BOOK_CODE ='5092')AND(Sheet1$。AGENT_NO ='943776')或(Sheet1$。BAL_BOOK_CODE ='509A')AND(Sheet1$。 AGENT_NO = '943776')