Solved

Substring??? MID????

Posted on 2002-04-30
13
457 Views
Last Modified: 2008-03-17
I am trying to get this query to work and I am getting this error on this part...


ISNULL((SELECT SUM(dbo_pm30200.DOCAMNT) FROM dbo_PM30200
WHERE SUBSTRING(dbo_pm30200.DOCNUMBR,5,3) = "LDG" and dbo_upr00100.employid = dbo_pm30200.vendorid),0)

It says that it doesn't recognize SUBSTRING().

SUBSTRING
---------
APR-LDG
MAY LDG
OCT/LDG
LDG ACD
FEB LDG 02

(5) Records.


What else could I use instead?
0
Comment
Question by:vbjohn
[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
  • 7
  • 6
13 Comments
 
LVL 12

Expert Comment

by:Paurths
ID: 6981820
mid


mid(string, startposition, length)

cheers
Ricky
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6981826
or,

... where dbo_pm30200.DOCNUMBR like '*LDG*'...
0
 

Author Comment

by:vbjohn
ID: 6981847
Both of those do not work.  Thanks anyways.
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 12

Expert Comment

by:Paurths
ID: 6981882
ok,

the name of your table is 'dbo_pm30200', and the name of the field is 'DOCNUMBR', correct?


does this query work?

SELECT dbo_pm30200.DOCNUMBR
FROM dbo_pm30200
WHERE (((dbo_pm30200.DOCNUMBR) Like "*ldb*"));
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6981884
ldb, should be ldg ofourse...
0
 

Author Comment

by:vbjohn
ID: 6981896
Yes that query works.
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6981916
what is the exact sql-string u are using now?
and what is your goal?
0
 

Author Comment

by:vbjohn
ID: 6981927
Yes that query works.
0
 
LVL 12

Accepted Solution

by:
Paurths earned 50 total points
ID: 6981931
SELECT Sum(dbo_pm30200.DOCAMNT) FROM dbo_pm30200
WHERE (((dbo_pm30200.DOCNUMBR) Like "*ldb*") AND (([dbo_upr00100].[emplyid])=[dbo_pm30200].[vendorid]));
0
 

Author Comment

by:vbjohn
ID: 6983495
It seems like you can not have a query inside of a query.

For example:

SELECT RTRIM(LASTNAME) + ', ' + RTRIM(FRSTNAME)
    + ' ' + RTRIM(MIDLNAME) AS NAME, INACTIVE, ISNULL
        ((SELECT (dbo_UPR00400.MTDWAGES_1 + dbo_UPR00400.MTDWAGES_2+ dbo_UPR00400.MTDWAGES_3 + dbo_UPR00400.MTDWAGES_4+ dbo_UPR00400.MTDWAGES_5 + dbo_UPR00400.MTDWAGES_6+ dbo_UPR00400.MTDWAGES_7 + dbo_UPR00400.MTDWAGES_8+ dbo_UPR00400.MTDWAGES_9 + dbo_UPR00400.MTDWAGES_10+ dbo_UPR00400.MTDWAGES_11 + dbo_UPR00400.MTDWAGES_12) AS Wages
FROM dbo_UPR00400
WHERE dbo_UPR00100.EMPLOYID = dbo_UPR00400.EMPLOYID AND
dbo_UPR00400.PAYTYPE = 5 AND
dbo_UPR00400.PAYRCORD = '1SPSES'), 0) As PDTotal
FROM dbo_UPR00100 INNER JOIN dbo_UPR00400 ON dbo_UPR00400.EMPLOYID = dbo_UPR00100.EMPLOYID
ORDER BY dbo_UPR00100.EMPLOYID;


Is there a way to do it in Access?



John-
0
 

Author Comment

by:vbjohn
ID: 6983815
Using another Question....
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6983934
sure u can use another 'Select...' statement in another

u should have made clear u wanted a 0, or a number with that ISNULL statement...
0
 

Author Comment

by:vbjohn
ID: 6986494
Thanks for the help on the Wildcard thing!
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

696 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