Question

SQL - MS Access Query Conversion

Asked by: PANKAJPARIKH

Hi,
I'm trying to convert the below listed SQL query in MS Access query format. But many functions available in SQL are not used in MS Access (eg: CASE, substr, NVL..etc) ..Could you please assist.

SELECT l.learner_number , NVL (a.offering_delivery_method, 'Ad-hoc') AS delivery_type , 
       Case 
       when substr(o.offering_id,1,5) = 'dowbt' 
       then o.wbt4 
       else o.ilt4 
       END Delivery_Development_Type , sum (a.learning_hours) 
FROM (SELECT a.learner_id, a.delivery_id, a.course_vendor_name,
               a.completion_date, a.action_status, a.completion_status,
               a.offering_template_id, a.offering_id, a.DURATION,
               a.course_title, a.course_number, a.learning_hours,
               CASE
                  WHEN a.delivery_id IS NULL
                  AND LOWER (a.course_vendor_name) LIKE '%skl%st%'
                     THEN 'E-Learning'
                  WHEN a.delivery_id IS NOT NULL
                     THEN a.offering_delivery_method
               END offering_delivery_method
          FROM usa.dtv_bv_offering_action a) a
       JOIN
       usa.dtv_bv_learners l ON l.learner_id = a.learner_id
       LEFT OUTER JOIN 
       usa.dtv_bv_offerings o ON o.offering_id = a.offering_id
 WHERE a.completion_status = 'Successful'
   AND a.action_status = 'Completed'
   AND a.completion_date >= TO_DATE ('2009/05/31 00:00:00', 'YYYY/MM/DD hh24:mi:ss')
   AND a.completion_date <= TO_DATE ('2009/06/24 23:59:59', 'YYYY/MM/DD hh24:mi:ss')
   AND LENGTH (TRIM (TRANSLATE (a.learning_hours, '.0123456789', ' '))) IS NULL
GROUP BY l.learner_number,nvl(a.offering_delivery_method,'Ad-hoc'),
Case when substr(o.offering_id,1,5) = 'dowbt' then o.wbt4 else o.ilt4 END;

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-08-01 at 12:05:18ID24619116
Tags

MS Access

,

PL / SQL Conversion

Topics

Microsoft Access Database

,

Access Coding/Macros

,

SQL Query Syntax

Participating Experts
3
Points
500
Comments
24

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Searching substring in SQL-query
    How to use substr-search in a SQL-query ? Must be something like : select * from table where substr('abc',city)
  2. NVL in SQL
    How can I get my VB5 to allow me to use the NVL function?
  3. A question related to NVL
    Hi Experts, I have a question regarding Using functions in where clasue, in fact it is a question for where clause Suppos, I have a query like SELECT count ( ROWID ) FROM table1 WHERE Upper ( Trim ( col1 ) ) = NVL ( :as_para, '' ) Now is the NVL operation pe...
  4. NVL within NVL...
    I am trying to acquire a field data using... NVL(field1, field2) however if field2 is still null, is it possible to still acquire another value from another field...? I've tried this statement below but it is not working... NVL(NVL(field1, field2), field3) also NVL(fie...
  5. Problem with the execution speed of a SQL query with the …
    Hi , I think here is an interesting and challenging problem I am facing with the execution speed of a SQL query executed with Oracle 9i. I have two tables 1) Employee and 2) Addresses. Both tables contains 90000 records each. I have written a...
  6. NVL Equivalent in Query of Queries
    I am doing a query of queries and would like to use the Oracle equivalent of NVL(column,value) but apparently QoQ does not support this...is there something equivalent that can be put into the CF SQL to accomplisih the same thing...is there a guide to CF SQL syntax and functi...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: Helen_FeddemaPosted on 2009-08-01 at 12:45:00ID: 24996384

Nz can just be substituted for NVL.

The syntax for InStr is:  InStr([start,] string1, string2 [, compare])

Select Case is used like this:

Select Case varValue
    Case 1
        'Some code
    Case 2
        'Some code
End Select

In your code, with just Null and non-Null alternatives, you could just use an If ... ElseIf ... End if structure instead.

 

by: Helen_FeddemaPosted on 2009-08-01 at 12:46:07ID: 24996389

I omitted to say that InStr can be used instead of Substr.  I think the argument positions are different.

 

by: mwvisa1Posted on 2009-08-01 at 14:05:05ID: 24996650

Additionally for CASE, IIF is available in MS Access as Helen indicated with If ... Else structure.

e.g., case structure like
Case
       when substr(o.offering_id,1,5) = 'dowbt'
       then o.wbt4
       else o.ilt4 end

becomes:
IIF(Mid(o.offering_id,1,5) = "dowbt", o.wbt4,  o.ilt4)

Notice MS Access uses double quotes (") and MID function can simulate substr(ing) whereas INSTR is more for finding the index of specific character or text within a string.  A nice function to be aware of though.

If you have If ... ElseIf ... End type scenarios, just do this:

IIF(Mid(o.offering_id,1,5) = "dowbt", o.wbt4,  IIF({some other condition}, o.ilt4, null))

Other things to note,  '%abc%' typically in MS Access is "*abc*" to signify a wildcard match to 'abc' with any amount of text around front/back.

Hope that helps.

Regards,
mwvisa1

 

by: aikimarkPosted on 2009-08-02 at 09:34:11ID: 24999343

This should be close.  However, I'm not sure what is being done with the PL/SQL Translate() function.

SELECT l.learner_number , a.offering_delivery_method AS delivery_type , 
       Delivery_Development_Type , 
      sum (a.learning_hours) 
 
FROM (SELECT a.learner_id, a.delivery_id, a.course_vendor_name,
               a.completion_date, a.action_status, a.completion_status,
               a.offering_template_id, a.offering_id, 
               IIF(MID(o.offering_id,1,5) = 'dowbt' , o.wbt4 , o.ilt4 ) AS Delivery_Development_Type , 
               a.DURATION,
               a.course_title, a.course_number, a.learning_hours,
               IIF(ISNULL(a.delivery_id) AND LOWER (a.course_vendor_name) LIKE "*skl*st*",
                   'E-Learning', IIF(ISNULL(a.delivery_id) , 'Ad-hoc', a.offering_delivery_method))
                  AS offering_delivery_method
       FROM usa.dtv_bv_offering_action a) a
           INNER JOIN usa.dtv_bv_learners l ON l.learner_id = a.learner_id
       LEFT JOIN 
          usa.dtv_bv_offerings o ON o.offering_id = a.offering_id
 WHERE a.completion_status = 'Successful'
   AND a.action_status = 'Completed'
   AND a.completion_date BETWEEN #2009/05/31 00:00:00# AND #2009/06/24 23:59:59#
   AND LENGTH (TRIM (TRANSLATE (a.learning_hours, '.0123456789', ' '))) IS NULL
 
GROUP BY l.learner_number,  a.offering_delivery_method, Delivery_Development_Type

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:

Select allOpen in new window

 

by: PANKAJPARIKHPosted on 2009-08-02 at 10:27:54ID: 24999549

@aikimark: Thanks a ton for the query, but the query does not execute due to Join issue's. Can you please help me analyse the joins.

 

by: mwvisa1Posted on 2009-08-02 at 11:17:38ID: 24999803

Try putting parenthesis around JOIN and WHERE clause criteria for MS Access.  If that doesn't work, you can change the JOIN statements to :

from tablea, tableb
where tablea.field = tableb.field

I think it is better to use ANSI join syntax where possible, but worth trying.

 

by: aikimarkPosted on 2009-08-02 at 14:38:29ID: 25000641

* I've removed columns in the FROM source query that weren't used in the outer query for efficiency.

* Corrected parenthesis for table joins

What does your a.learning_hours column look like?  I still don't know how to treat the last condition of the WHERE clause.

SELECT learner_number , offering_delivery_method AS delivery_type , 
      Delivery_Development_Type , sum(learning_hours) AS TotalHours
 
FROM (SELECT 
      IIF(MID(o.offering_id,1,5) = 'dowbt' , o.wbt4 , o.ilt4 ) AS Delivery_Development_Type , 
      a.learning_hours, l.learner_number, 
      IIF(ISNULL(a.delivery_id) AND LOWER (a.course_vendor_name) LIKE "*skl*st*",
         'E-Learning', IIF(ISNULL(a.delivery_id) , 'Ad-hoc', a.offering_delivery_method))
         AS offering_delivery_method
 
      FROM (usa.dtv_bv_offering_action a
          INNER JOIN usa.dtv_bv_learners l ON l.learner_id = a.learner_id)
          LEFT JOIN usa.dtv_bv_offerings o ON o.offering_id = a.offering_id
 
      WHERE a.completion_status = 'Successful'
          AND a.action_status = 'Completed'
          AND a.completion_date BETWEEN #2009/05/31 00:00:00# AND #2009/06/24 23:59:59#
          AND LENGTH (TRIM (TRANSLATE (a.learning_hours, '.0123456789', ' '))) IS NULL
 
GROUP BY l.learner_number,  a.offering_delivery_method, Delivery_Development_Type
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:

Select allOpen in new window

 

by: mwvisa1Posted on 2009-08-02 at 15:13:39ID: 25000779

And I meant these parenthesis also, so the join and where clauses.  Also try the ODBC canonical format for date.

Also, try REPLACE instead of TRANSLATE:
http://www.techonthenet.com/access/functions/string/replace.php

LEN instead of LENGTH:
http://www.techonthenet.com/access/functions/string/len.php

PL/SQL LENGTH returns NULL if the value passed is NULL.  You may need to use 0 for MS Access.

SELECT learner_number , offering_delivery_method AS delivery_type , 
      Delivery_Development_Type , sum(learning_hours) AS TotalHours
 
FROM (SELECT 
      IIF(MID(o.offering_id,1,5) = "dowbt" , o.wbt4 , o.ilt4 ) AS Delivery_Development_Type , 
      a.learning_hours, l.learner_number, 
      IIF(ISNULL(a.delivery_id) AND LOWER (a.course_vendor_name) LIKE "*skl*st*",
         "E-Learning", IIF(ISNULL(a.delivery_id) , "Ad-hoc", a.offering_delivery_method))
         AS offering_delivery_method
 
      FROM (usa.dtv_bv_offering_action a
          INNER JOIN usa.dtv_bv_learners l ON (l.learner_id = a.learner_id))
          LEFT JOIN usa.dtv_bv_offerings o ON (o.offering_id = a.offering_id)
 
      WHERE (a.completion_status = "Successful")
          AND (a.action_status = "Completed")
          AND (a.completion_date BETWEEN #2009-05-31 00:00:00# AND #2009-06-24 23:59:59#)
          AND (LEN(TRIM(REPLACE(a.learning_hours, ".0123456789", " "))) = 0)
) t
GROUP BY l.learner_number,  a.offering_delivery_method, Delivery_Development_Type

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:

Select allOpen in new window

 

by: mwvisa1Posted on 2009-08-02 at 15:18:02ID: 25000802

Sorry I see a type-o with the parenthesis.  Thought it was missing the closing one, so I added the ') t' to close it, but it should have been earlier as the alias 'a' is really for the derived table.  I was going to fix, but now I see that the original query was altered too much, so will have to start from your own base and apply the techniques I told you.  For example, the derived table should only have columns from table a then join to the others.  The fields for other tables should be in the outer query.

 

by: aikimarkPosted on 2009-08-02 at 15:24:11ID: 25000838

@mwvisa1

Thanks.  I'd missed the closing parens.

Do you have any idea what they are trying to accomplish with the a.learning_hours field manipulation?  If non-numeric hours, then how would we be able to sum them?!?

It seems to me that the TRIM function would superfluous if the REPLACE function used an empty string.

AND (LEN(REPLACE(a.learning_hours, ".0123456789", "")) = 0)
                                              
1:

Select allOpen in new window

 

by: mwvisa1Posted on 2009-08-02 at 15:32:23ID: 25000877

Try like this;

SELECT l.learner_number
, NZ(a.offering_delivery_method, "Ad-hoc") AS delivery_type 
, IIF(Mid(o.offering_id,1,5) = "dowbt", o.wbt4, o.ilt4) AS Delivery_Development_Type
, sum (a.learning_hours)
FROM (
   SELECT learner_id, delivery_id, course_vendor_name,
   completion_date, action_status, completion_status,
   offering_template_id, offering_id, DURATION,
   course_title, course_number, learning_hours,
   IIF(ISNULL(delivery_id)=1 AND LCASE(course_vendor_name) LIKE "*skl*st*", "E-Learning", offering_delivery_method) AS offering_delivery_method
   FROM usa.dtv_bv_offering_action
) a 
INNER JOIN usa.dtv_bv_learners l ON (l.learner_id = a.learner_id))
LEFT OUTER JOIN usa.dtv_bv_offerings o ON (o.offering_id = a.offering_id)
WHERE (a.completion_status = "Successful")
AND (a.action_status = "Completed")
AND ((a.completion_date >= #2009-05-31 00:00:00#)
   AND (a.completion_date <= #2009-06-24 23:59:59#))
AND (LEN(TRIM(REPLACE(a.learning_hours, ".0123456789", " "))) = 0)
GROUP BY l.learner_number, NZ(a.offering_delivery_method, "Ad-hoc"), IIF(Mid(o.offering_id,1,5) = "dowbt", o.wbt4, o.ilt4);

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:

Select allOpen in new window

 

by: mwvisa1Posted on 2009-08-02 at 15:37:17ID: 25000906

Yeah not sure either.  I know TRANSLATE is like REPLACE, but possibly it allows regular expression which that is meant to replace all numbers and then that would be making sure that you only have numeric value so possible:

(LEN(TRIM(REPLACE(a.learning_hours, ".0123456789", " "))) = 0)

could be replaced with:

(ISNUMERIC(a.learning_hours) = TRUE)

http://www.techonthenet.com/access/functions/advanced/isnumeric.php

And if that is the case, then probably also want to change:

SUM(a.learning_hours)

to:

SUM(CDBL(a.learning_hours))

 

by: mwvisa1Posted on 2009-08-02 at 15:39:38ID: 25000922

And so:
(ref. http://www.techonthenet.com/access/functions/datatype/cdbl.php)

SELECT l.learner_number
, NZ(a.offering_delivery_method, "Ad-hoc") AS delivery_type 
, IIF(Mid(o.offering_id,1,5) = "dowbt", o.wbt4, o.ilt4) AS Delivery_Development_Type
, SUM(CDBL(a.learning_hours))
FROM (
   SELECT learner_id, delivery_id, course_vendor_name,
   completion_date, action_status, completion_status,
   offering_template_id, offering_id, DURATION,
   course_title, course_number, learning_hours,
   IIF(ISNULL(delivery_id) AND LCASE(course_vendor_name) LIKE "*skl*st*", "E-Learning", offering_delivery_method) AS offering_delivery_method
   FROM usa.dtv_bv_offering_action
) a 
INNER JOIN usa.dtv_bv_learners l ON (l.learner_id = a.learner_id))
LEFT OUTER JOIN usa.dtv_bv_offerings o ON (o.offering_id = a.offering_id)
WHERE (a.completion_status = "Successful")
AND (a.action_status = "Completed")
AND ((a.completion_date >= #2009-05-31 00:00:00#)
   AND (a.completion_date <= #2009-06-24 23:59:59#))
AND (ISNUMERIC(a.learning_hours))
GROUP BY l.learner_number, NZ(a.offering_delivery_method, "Ad-hoc"), IIF(Mid(o.offering_id,1,5) = "dowbt", o.wbt4, o.ilt4);

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:

Select allOpen in new window

 

by: aikimarkPosted on 2009-08-02 at 15:55:18ID: 25000976

@mwvisa1

Why drop back to the original query?  I don't think it was well written.

I think you are correct with your IsNumeric() hypothesis.

SELECT learner_number , offering_delivery_method AS delivery_type , 
      Delivery_Development_Type , Sum(CDBL(learning_hours)) AS TotalHours
 
FROM (SELECT 
      IIF(MID(o.offering_id,1,5) = "dowbt" , o.wbt4 , o.ilt4 ) AS Delivery_Development_Type , 
      a.learning_hours, l.learner_number, 
      IIF(ISNULL(a.delivery_id) AND LOWER (a.course_vendor_name) LIKE "*skl*st*",
         "E-Learning", IIF(ISNULL(a.delivery_id) , "Ad-hoc", a.offering_delivery_method))
         AS offering_delivery_method
 
      FROM (usa.dtv_bv_offering_action a
          INNER JOIN usa.dtv_bv_learners l ON (l.learner_id = a.learner_id))
          LEFT JOIN usa.dtv_bv_offerings o ON (o.offering_id = a.offering_id)
 
      WHERE (a.completion_status = "Successful")
          AND (a.action_status = "Completed")
          AND (a.completion_date BETWEEN #2009-05-31 00:00:00# AND #2009-06-24 23:59:59#)
          AND (IsNumeric(a.learning_hours) = True)
) t
 
GROUP BY learner_number, offering_delivery_method, Delivery_Development_Type
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:

Select allOpen in new window

 

by: aikimarkPosted on 2009-08-02 at 16:02:07ID: 25001000

I think a more reliable method in PL/SQL would be a function like I've pasted into the snippet.

Source: http://psoug.org/reference/functions.html
________________

CREATE OR REPLACE FUNCTION is_number(char_in VARCHAR2) RETURN BOOLEAN IS
 n NUMBER;
BEGIN
  n := TO_NUMBER(char_in);
  RETURN TRUE; 
EXCEPTION
  WHEN OTHERS THEN
    RETURN FALSE;
END is_number;

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:

Select allOpen in new window

 

by: mwvisa1Posted on 2009-08-02 at 16:03:30ID: 25001004

I thought I was messing up the typing of changes as I was referring back to the original post but it didn't match.  I see now that you corrected the query to be more efficient and my addition of ') t' was appropriate since you made the whole thing a derived table. :) Thought I goofed and that is why I started back from scratch.  Nice job.  Is it LOWER instead of LCASE?

 

by: mwvisa1Posted on 2009-08-02 at 16:06:57ID: 25001016

@PANKAJPARIKH, you following all this?

 

by: aikimarkPosted on 2009-08-02 at 16:08:00ID: 25001021

Thanks again. You are correct about LOWER -> LCASE. It's a bit difficult to catch everything.

Good to have an extra set of eyes.

SELECT learner_number , offering_delivery_method AS delivery_type , 
      Delivery_Development_Type , Sum(CDBL(learning_hours)) AS TotalHours
 
FROM (SELECT 
      IIF(MID(o.offering_id,1,5) = "dowbt" , o.wbt4 , o.ilt4 ) AS Delivery_Development_Type , 
      a.learning_hours, l.learner_number, 
      IIF(ISNULL(a.delivery_id) AND LCASE(a.course_vendor_name) LIKE "*skl*st*",
         "E-Learning", IIF(ISNULL(a.delivery_id) , "Ad-hoc", a.offering_delivery_method))
         AS offering_delivery_method
 
      FROM (usa.dtv_bv_offering_action a
          INNER JOIN usa.dtv_bv_learners l ON (l.learner_id = a.learner_id))
          LEFT JOIN usa.dtv_bv_offerings o ON (o.offering_id = a.offering_id)
 
      WHERE (a.completion_status = "Successful")
          AND (a.action_status = "Completed")
          AND (a.completion_date BETWEEN #2009-05-31 00:00:00# AND #2009-06-24 23:59:59#)
          AND (IsNumeric(a.learning_hours) = True)
     ) t
 
GROUP BY learner_number, offering_delivery_method, Delivery_Development_Type
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:

Select allOpen in new window

 

by: mwvisa1Posted on 2009-08-02 at 16:12:32ID: 25001040

@aikimark, very nice.  I think you got it.  At least that all looks like good MS Access code to me.  Will just have to see how PANKAJPARIKH responds. :)

 

by: PANKAJPARIKHPosted on 2009-08-09 at 10:21:25ID: 31610541

Awesome, Genius..

 

by: aikimarkPosted on 2009-08-09 at 10:29:45ID: 25055005

Thanks for the points.

Note: If you are trying to run a PL/SQL query from an MS-Access database, you don't necessarily have to convert it to Jet SQL.  You can save the Oracle SQL in a stored (Access) query that is run as a pass-through query.  The Jet engine does not look at the SQL for pass-through queries.

 

by: PANKAJPARIKHPosted on 2009-08-09 at 11:08:23ID: 25055190

Sure, aikimark...Thanks a ton for the suggestion ;)

 

by: mwvisa1Posted on 2009-08-09 at 11:09:43ID: 25055199

Glad we were able to help you...

Happy coding!

Regards,

isa

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...