?
Solved

SQL VIEW

Posted on 2013-01-17
7
Medium Priority
?
268 Views
Last Modified: 2013-01-17
Hi,

Im not used to working with SQL view. I am trying to put the condition

"SC" into field DR/CR

The SQL is

INSERT INTO [A1 - APAC Data] ( SEC, [WINNAR NO], LEDGER, [DR/CR], CCY, AMOUNT, [VALUE], [AGE BY VALUE], ENTRY_DATE, SFIELD_7, SFIELD_8, SFIELD_9, TRAN_CODE, GBP_EQUIV, [Root Cause] )
SELECT [1 - Import APAC].SEC, [1 - Import APAC].[WINNAR NO#], [1 - Import APAC].LEDGER, [1 - Import APAC].[DR/CR], [1 - Import APAC].CCY, [1 - Import APAC].AMOUNT, [1 - Import APAC].VALUE, Val(Replace([1 - Import APAC]![AGE BY VALUE]," days","",1)) AS Expr1, [1 - Import APAC].ENTRY_DATE, [1 - Import APAC].SFIELD_7, [1 - Import APAC].SFIELD_8, [1 - Import APAC].SFIELD_9, [1 - Import APAC].TRAN_CODE, [1 - Import APAC].GBP_EQUIV, [1 - Import APAC].[Root Cause]
FROM [1 - Import APAC];


Can anyone amend the code to include that condition?

Thanks
0
Comment
Question by:Seamus2626
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 38787452
INSERT INTO [A1 - APAC Data] ( SEC, [WINNAR NO], LEDGER, [DR/CR], CCY, AMOUNT, [VALUE], [AGE BY VALUE], ENTRY_DATE, SFIELD_7, SFIELD_8, SFIELD_9, TRAN_CODE, GBP_EQUIV, [Root Cause] )
SELECT [1 - Import APAC].SEC, [1 - Import APAC].[WINNAR NO#], [1 - Import APAC].LEDGER, [1 - Import APAC].[DR/CR], [1 - Import APAC].CCY, [1 - Import APAC].AMOUNT, [1 - Import APAC].VALUE, Val(Replace([1 - Import APAC]![AGE BY VALUE]," days","",1)) AS Expr1, [1 - Import APAC].ENTRY_DATE, [1 - Import APAC].SFIELD_7, [1 - Import APAC].SFIELD_8, [1 - Import APAC].SFIELD_9, [1 - Import APAC].TRAN_CODE, [1 - Import APAC].GBP_EQUIV, [1 - Import APAC].[Root Cause]
FROM [1 - Import APAC]  WHERE [DR/CR] = "SC"

Open in new window

0
 

Author Closing Comment

by:Seamus2626
ID: 38787464
Thanks mbizup!

Seamus
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38787488
Glad to help!  

Cleaning the syntax a little:

INSERT INTO [A1 - APAC Data] ( SEC, [WINNAR NO], LEDGER, [DR/CR], CCY, AMOUNT, [VALUE], [AGE BY VALUE], ENTRY_DATE, SFIELD_7, SFIELD_8, SFIELD_9, TRAN_CODE, GBP_EQUIV, [Root Cause] )
SELECT Imp.SEC,  Imp.WINNAR NO#],  Imp.LEDGER, Imp.DR/CR],  Imp.CCY,  Imp.AMOUNT, Imp.VALUE, Val(Replace([1 -  Imp![AGE BY VALUE]," days","",1)) AS Expr1,  Imp.ENTRY_DATE,  Imp.SFIELD_7, Imp.SFIELD_8,  Imp.SFIELD_9,  Imp.TRAN_CODE, Imp.GBP_EQUIV,  Imp.[Root Cause]
FROM [1 - Import APAC] Imp WHERE  Imp.[DR/CR] = "SC"

Open in new window


Ideally all those field and table names should be changed to not include spaces or special characters.
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

Author Comment

by:Seamus2626
ID: 38787495
Why is that out of interest?

Thanks
0
 
LVL 26

Expert Comment

by:jerryb30
ID: 38787779
See this:
http://support.microsoft.com/kb/826763
Ideally, MS Access would catch all of these when naming fields, but it does not.  And, use of some of these 'reserved'  characters can be allowed by use of brackets. But they may not work in other databases and code, such as vba.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38787824
Sorry I missed your comment -  I got the email notif for Jerry's comment though.  :-)

Anyhow, just seconding what he said...

Not just for table and field names... but for variables, objects, etc.

Reserved words, spaces and special characters can cause real problems in code and queries.  Not only does your code etc look cleaner when you steer clear of them, but you can omit those brackets, and count it as one less thing to go wrong.

Most of the regulars here use the Reddick VBA (or similar) conventions for naming objects, fields.  Standards specific to Access are midway down the page:
http://www.xoc.net/standards/rvbanc.asp
0
 

Author Comment

by:Seamus2626
ID: 38787847
Okay, i see.

Thanks for the heads up guys
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question