Home > Software engineering >  Please take a look at this from ACCESS statement to SQL SERVER statement why errors
Please take a look at this from ACCESS statement to SQL SERVER statement why errors

Time:10-04

Table structure is as follows:
1, yhxx table: user id username state

2, SDJL table:
User id user name table number name of phenotypic charging type category number of unit price to buy buy buy amount fee type operation date operator number operation effectiveness paper order revision number
3, yueb table:
User id paid-in amount cash balance balance bill number total number operation date last time operation type

Please take a look at this from ACCESS statement to SQL SERVER statement why tip error: near the keyword AS a syntax error

SELECT sum (c. purchase amount) as total amount
The From
(
(
(SELECT user id FROM yhxx WHERE user id=10007) AS a
Left the Join
(
SELECT the user number, purchase amount, paper number, operation type, validity, revision number FROM SDJL WHERE user id number=141110007=10007 AND paper AND effectiveness=type='buy' AND 'effective'
The Union
SELECT the user number, purchase amount, paper number, operation type, validity, revision number FROM SDJL b1
WHERE user id number=141110007=10007 AND paper AND effectiveness=type='buy' AND 'invalid'
AND revision number=
(
The SELECT MAX (fixed number) FROM SDJL b2
WHERE user id=10007 AND the bill number=141110007 AND operation type='buy'
='invalid' AND effectiveness AND b2. The table number=b1. The table number
)
User id=) AS b ON a. b. user id
) AS c
Left the Join
(SELECT the user number, bill number FROM yueb WHERE user id=10007 AND paper number=141110007) AS d
ON c. user id=d. user number AND c. paper number=d. paper number) order by c. user number) t

Please have a look at it,

CodePudding user response:

First:
Purchase amount [color=# # FF0000], [/color] paper number
Chinese punctuation

Second: SQL Server each As the front must have corresponding the FROM or JOIN, actually can be directly multi-table connection, not like Access connection once will add a bracket,
 SELECT... 
The FROM (... ) AS a
LEFT the JOIN (... B) AS ON...
LEFT the JOIN (... C) AS ON...
LEFT the JOIN (... D) AS ON...

CodePudding user response:

reference 1st floor Tiger_Zhao response:
first:
Purchase amount [color=# # FF0000], [/color] paper number
Chinese punctuation

Second: SQL Server each As the front must have corresponding the FROM or JOIN, actually can be directly multi-table connection, not like Access connection once will add a bracket,
 SELECT... 
The FROM (... ) AS a
LEFT the JOIN (... B) AS ON...
LEFT the JOIN (... C) AS ON...
LEFT the JOIN (... D) AS ON...




reference 1st floor Tiger_Zhao response:
first:
Purchase amount [color=# # FF0000], [/color] paper number
Chinese punctuation

Second: SQL Server each As the front must have corresponding the FROM or JOIN, actually can be directly multi-table connection, not like Access connection once will add a bracket,
 SELECT... 
The FROM (... ) AS a
LEFT the JOIN (... B) AS ON...
LEFT the JOIN (... C) AS ON...
LEFT the JOIN (... D) AS ON...

That makes sense,
  • Related