Comparison Charts

Hi @George and @Hyperbytes, are the any good examples of
How to setup VIEWS in MySQL?
and then
How to use those VIEWS in Wappler ?

I just set them up in Navicat then they become visible to Wappler just like a database table would. It’s no different to writing a query really. You may need to set Prepared Statements from Auto to True in some cases

1 Like

I know it’s probably very simple, but are there any tuts/vids on the web that you know of that are worth a quick VIEW !!
See what I did there! :smile:

Please check:

https://www.w3schools.com/sql/sql_intro.asp
https://www.w3schools.com/sql/sql_view.asp

2 Likes

Thanks Brian! I tried out both ways and they work wonderfully. I can’t thank you enough. I learned a lot just by dissecting what you did. I ended up going with the custom query method as you are correct, the next step would be to be able to choose between two dates. I think I can figure that out. But I have one question that has me stumped.

How can I set the ORDER BY so that the hours are in the proper order starting at 8 AM going to 5 PM?

Delighted to have helped!

Try just adding “ORDER BY Hours” at the end of the query

I already tried that. I also tried:

order by date_format(Hours,'%I %p')

Sorry of course, the format is 12 hour format with AM /PM after, not simply a number

Problem lies with your formatting of the Hours .i.e 09 AM, 05 PM etc
The sort by sorts them alphabetically with of course is wrong due to the format.

I suggest you need to use a 24Hr format column (%k than than '%I %p) and add that column name to the initial select

If you want to retain the formatting then add an additional column to the 3 query stages, i.e.

date_format(t_trackervisits.track_time,‘k’) AS `Hours24

then use that column as the basis for the sort

Think that should do the trick (not actually tried - sorry)

If you have problems, i will look at it for you tomorrow (7.30pm here, time to eat)

Yes, changing to 24 hour clock solved the ordering issue. Now I just gotta figure out how to display the 12 hour time on the axis. :slight_smile:

Thanks so much again, Brian. I am forever in debt to you. Learned a ton!

1 Like

Ye, thats why I suggested the additional column in 24 hr format, so you could order the query on it but display the AM/PM formatted column in the chart

Yeah I tried that but for some reason the new column does not get picked up by the Schema.

Ok, doing this from phone so can just give idea, not code but idea for formatting
Take your 24 hrs time

Modulus (%) Hours 12 gives 0 - 12 range.
Pad to 2 digits with 0 if needed
(edit probably need to transform 00 to 12 also using replace)
Concatenate result with {{Hours>=12?‘PM’:‘AM’}}

Thanks, Brian! I will research the MOD() function and see if I can figure it out.

I have success! I figured out where I was going wrong using this method. I have it solved and on to the next step filtering by dates. This I think I know how to do though and can handle that part.

I really owe ya some beers, Brian!

I can go to bed now with a satisfied smile on my wife, congratulations brad

2 Likes

Lol, just read this, autosuggest made that sound very wrong, should have said smile in my face, made my comment sound very raunchy!

3 Likes

Have to admit, I did chuckle at the typo when first reading but thought it best to let it stand. :grimacing:

My first thought was that I should be congratulating you! :wink: