Trying to use "Insert into temp2" instead of this "Select into temp2" code in MS Access

Hedgebox

But cannot seem to be able to convert it to an Insert.

The below outputs the fields I need in the order I need them into a new table "temp2". However, I am trying to append them to an existing table "Indices_Data" rather than creating a new table "temp2".

SELECT * INTO temp2 FROM (SELECT TOP 60 [Date],[Security],[Close],[High],[Low],[Return], [CompoundReturn],[High]-[Low] as [R1],[R1]/(([High] + [Low])*.05) as R2, [Return]^2 as ReturnSqrd,[CompoundReturn]^2 as CompoundReturnSqrd FROM Indices_WS where Security ='BEL20 Index' Order by [Date] Desc) AS temp ORDER BY temp.Date;

Thanks in advance.

Not a Duplicate..I have looked at this and some other comments on what appear to be similar issues. The complication comes Insert into with the use of Select "Top" and using it on Dates requiring order by to be desc to get the most recent records...{making that "temp"} then changing the sort by to asc

June7

Specify the fields you want to insert data into. Use SELECT to pull the data.

INSERT INTO Indices_Data([Date], [Security], [Close], [High], [Low], [Return], [CompoundReturn], [R1], [R2], ReturnSqrd, CompoundReturnSqrd) SELECT TOP 60 [Date], [Security], [Close], [High], [Low], [Return], [CompoundReturn], [High]-[Low] As [R1], [R1]/(([High] + [Low])*.05) As R2, [Return]^2 As ReturnSqrd, [CompoundReturn]^2 As CompoundReturnSqrd FROM Indices_WS where Security ='BEL20 Index' ORDER BY [Date] Desc;

If you must save in ASC order:

INSERT INTO Indices_Data([Date], [Security], [Close], [High], [Low], [Return], [CompoundReturn], [R1], [R2], ReturnSqrd, CompoundReturnSqrd) SELECT * FROM (SELECT TOP 60 [Date], [Security], [Close], [High], [Low], [Return], [CompoundReturn], [High]-[Low] As [R1], [R1]/(([High] + [Low])*.05) As R2, [Return]^2 As ReturnSqrd, [CompoundReturn]^2 As CompoundReturnSqrd FROM Indices_WS where Security ='BEL20 Index' ORDER BY [Date] Desc) AS T ORDER BY [Date] ASC;

Saving calculated (data dependent on other data) values is usually a bad design. Do the calcs when needed.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Error when trying to use to "Insert into" a ms-access database

From Dev

Would you use a macro or VBA code with MS-Access?

From Dev

Inheritance for VBA code in MS Access

From Dev

MS Access Update Area Code

From Dev

Trying to reproduce a MySQL query in MS Access

From Dev

Am trying to categorise values using Ms Access

From Dev

How to use DISTINCT in ms access?

From Dev

Java exception in Mathematica while trying to access MS Access

From Dev

use java code instead of XML?

From Dev

Using MS Access to run code in excel vba

From Dev

MS Access/ VBA : add if condition to vba code

From Dev

MS Access run code after a row is updated

From Dev

Is there a way to "view the code" of a MS Access file?

From Dev

Using MS Access to run code in excel vba

From Dev

MS Access: Execute code for every instance of a subsubform

From Dev

SQL Server export to Excel and MS Access in code

From Dev

MS Access viewing the code of bottom navigations?

From Java

How to use mod function for linq to ms access?

From Dev

How to use Left function with MS Access 2007

From Dev

Use SQL Server Express engine in MS Access

From Dev

Use a query to sort a report in MS Access

From Dev

Custom use of count function in ms access

From Dev

to use module in sql ms-Access-2010

From Dev

Access denied when trying to run stored procedure on MS SQL Server

From Dev

In MS Access 2010 I'm trying to ignore a duplicate entry in a control

From Dev

Access denied when trying to run stored procedure on MS SQL Server

From Dev

Trying to edit a text field in MS Access, but it says it needs more parameters

From Dev

Trying to execute a query I converted from MS ACCESS

From Dev

MS Access is displaying copies of a first row instead of correct values

Related Related

  1. 1

    Error when trying to use to "Insert into" a ms-access database

  2. 2

    Would you use a macro or VBA code with MS-Access?

  3. 3

    Inheritance for VBA code in MS Access

  4. 4

    MS Access Update Area Code

  5. 5

    Trying to reproduce a MySQL query in MS Access

  6. 6

    Am trying to categorise values using Ms Access

  7. 7

    How to use DISTINCT in ms access?

  8. 8

    Java exception in Mathematica while trying to access MS Access

  9. 9

    use java code instead of XML?

  10. 10

    Using MS Access to run code in excel vba

  11. 11

    MS Access/ VBA : add if condition to vba code

  12. 12

    MS Access run code after a row is updated

  13. 13

    Is there a way to "view the code" of a MS Access file?

  14. 14

    Using MS Access to run code in excel vba

  15. 15

    MS Access: Execute code for every instance of a subsubform

  16. 16

    SQL Server export to Excel and MS Access in code

  17. 17

    MS Access viewing the code of bottom navigations?

  18. 18

    How to use mod function for linq to ms access?

  19. 19

    How to use Left function with MS Access 2007

  20. 20

    Use SQL Server Express engine in MS Access

  21. 21

    Use a query to sort a report in MS Access

  22. 22

    Custom use of count function in ms access

  23. 23

    to use module in sql ms-Access-2010

  24. 24

    Access denied when trying to run stored procedure on MS SQL Server

  25. 25

    In MS Access 2010 I'm trying to ignore a duplicate entry in a control

  26. 26

    Access denied when trying to run stored procedure on MS SQL Server

  27. 27

    Trying to edit a text field in MS Access, but it says it needs more parameters

  28. 28

    Trying to execute a query I converted from MS ACCESS

  29. 29

    MS Access is displaying copies of a first row instead of correct values

HotTag

Archive