Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Creating grid with SQL statement. Parse error on word 'Select'

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating grid with SQL statement. Parse error on word 'Select'

    Version 12 - 6488

    I have created a grid that merges 2 tables together. Basically, table 1 has names and id numbers, table 2 has id numbers and dates paid. I would love to have a button that produces the previous results with the following: each name listed only once with each duplicate hidden except for the most recent date. So, to start, I created the grid with an SQL statement listed below. This seems to work as I desire when I run it on the MySQL workbench, however when I run it in the grid, I get a parse error claiming to be on the 2nd "select" statement (that is in the 2nd left join).

    I have read other posts that seem similar, but none, that I have found, seem to resolve the issue. Can anyone point me in the right direction? I'd really appreciate it.

    Code:
    SELECT 
    	c.customersai,c.subAgency,c.NameLast,c.NameFirst,c.nameMiddle,c.DOB,c.mID,p.dtm02,p.denied 
    FROM customers c
    	 LEFT OUTER JOIN processed p
    		 ON  c.tenantid = p.tenantid  AND  c.mID = p.mID    
    	INNER JOIN (select mID as mid, max(dtm02) as maxdate from processed group by mID) sub
             on processed.mID = sub.mid and processed.dtm02 = sub.maxdate
    ORDER BY c.NameLast, c.NameFirst, c.nameMiddle, c.DOB

  • #2
    Re: Creating grid with SQL statement. Parse error on word 'Select'

    Have you tried making the groupedBy part of the query a separate view and joining that to the rest of the grid query? I have not parsed your expression but that has solved some complex groupedBy queries for me in the past.

    Comment


    • #3
      Re: Creating grid with SQL statement. Parse error on word 'Select'

      Hi Gary,
      I think I understand what you're trying to do but really need some sample data to test the code.
      I only see one left join, not two.
      Gregg
      https://paiza.io is a great site to test and share sql code

      Comment


      • #4
        Re: Creating grid with SQL statement. Parse error on word 'Select'

        Try this:

        SELECT
        c.customersai,c.subAgency,c.NameLast,c.NameFirst,c.nameMiddle,c.DOB,c.mID,p.dtm02,p.denied
        FROM customers c
        LEFT OUTER JOIN processed p
        ON c.tenantid = p.tenantid AND c.mID = p.mID
        ORDER BY c.NameLast, c.NameFirst, c.nameMiddle, c.DOB , p.dtm02 DESC
        GROUP BY c.NameLast, c.NameFirst, c.nameMiddle, c.DOB

        By adding p.dtm02 DESC to the order caluse, you are getting the most recent date first. Then, by doing a GROUP BY as last line, you will eliminate duplicate names and have only the name with the most recent date
        Gary S. Traub, Ph.D.

        Comment


        • #5
          Re: Creating grid with SQL statement. Parse error on word 'Select'

          Thank you Eric, Gregg, and Gary. Gary, your code works perfectly (I had to switch the order of Order By and Group By). That does exactly what I wanted. Thank you. I ended up putting this in a List in a UX. Thank you again.

          Comment


          • #6
            Re: Creating grid with SQL statement. Parse error on word 'Select'

            My pleasure - happy to be of help
            Gary S. Traub, Ph.D.

            Comment


            • #7
              Re: Creating grid with SQL statement. Parse error on word 'Select'

              I tried the list, and while it works, it is not as familiar as the grid. It also doesn't give me the search options I would like that the grid offers.

              When I put your statement into the grid's sql builder, minus the "group by," it works as one would expect without the group by, however when I add the group by back into the statement, it gives me the error "unexpected token: SELECT"

              Is there somewhere else I should be putting the group by line? Also, I have seen in other posts where creating a "View" was suggested. Eric also suggested it above, however I seem to be lost there. How does one create a view in a grid? I see under Grid, Query, there is a Table or View option, and I have used that extensively for referencing a single table, however, how do I create a view?

              Comment


              • #8
                Re: Creating grid with SQL statement. Parse error on word 'Select'

                Hi Gary,

                To create a view, put [Create view `myViewName` as] above your select statement.
                Gregg
                https://paiza.io is a great site to test and share sql code

                Comment


                • #9
                  Hi Gary,
                  The code below will create a view that I think will produce the information you want based on your original post.
                  I usually test my code, but have a rough time not knowing the specifics of your tables or the results you are really looking for.
                  I hope this helps.

                  Gregg

                  Code:
                  create view `myView` as
                  SELECT distinct c.customersai,c.subAgency,c.NameLast,c.NameFirst,c.nameMiddle,c.DOB,c.mID,p.dtm02,p.denied
                  FROM customers c
                  LEFT JOIN processed p ON c.tenantid = p.tenantid AND c.mID = p.mID
                  where c.tenantid = p.tenantid AND c.mID = p.mID and p.dtm02 = (select max(dtm02) from processed where tenantid = c.tenantid and mid = c.mid)
                  ORDER BY c.NameLast, c.NameFirst, c.nameMiddle, c.DOB , p.dtm02 DESC
                  Gregg
                  https://paiza.io is a great site to test and share sql code

                  Comment


                  • #10
                    Thank you madtowg. I would have replied sooner, but the forum was down. I feel like a bit of an idiot. I was looking all over Alpha to find out to create a view, and I never made the connection that it had to be done in MySQL. Setting Gary's recommendation up as a "view" seems to do the trick for me.

                    I have been learning as I go, and I have been working on AA (not the drinking one) almost full-time for the past 4 months. It is amazing what I have picked up, but it is also surprising to me how much I still don't know.

                    Thank you all again for all of your help. Everyone stay safe and healthy.

                    Comment


                    • #11
                      Glad you got it working. I did delete a post as I say you solved it.
                      Last edited by ecalan; 04-07-2020, 02:40 PM.

                      Comment

                      Working...
                      X