Had another quick question for you guys... I see that you have Min, Max, Avg, and Sum functions for your columns, but I cant seem to find anything about a Count function for string datatypes. Essentially what Id like to do is have a bar above my table that contain shortcodes that show how many Tanks are in each level status. So each user can see that there is ___ tanks in the "Low" status, ___ tanks in the "Critical" status, and so on. Any idea how I can go about doing this?
I am sorry to disappoint you, but unfortunately something like this is not possible with the plugin's built-in features.
Calculation functions can only be used on integer and float type columns.
If you need to place this above the table, on front-end, my advice is to create a separate SQL query based table, with a query similar to this:
SELECT levelStatus,
COUNT(levelStatus)
FROM yourTable
GROUP BY levelStatus
That way, you will have two columns in that new table:
Level Status | COUNT(levelStatus)
Low | 2
Normal | 13
Critical | 9
Then, you can count the SUM for that column, but it would show the total of all values from a column - in the above case 24, which is not what you want to achieve.
To achieve having a SUM for every value, you can try this query:
SELECT
( SELECT
COUNT(levelStatus)
FROM yourTable
WHERE state = 'Low'
) AS Low,
( SELECT
COUNT(levelStatus)
FROM yourTable
WHERE state = 'Normal'
) AS Normal,
( SELECT
COUNT(levelStatus)
FROM yourTable
WHERE state = 'Critical'
) AS Critical,
FROM yourTable
GROUP BY Low
And the table will look like this:
Low | Normal | Critical
2 | 13 | 9
Then you can calculate the for each of these columns, and use the SUM shortcode to display it on the page where the original table is:
Please note, though, that this sort of query will result in the SUM not to return the correct result, so you will need to disable server-side processing for this table.
I'm sorry, but JSON tables are not being stored in the database, so you can't pull them using SQL queries, unfortunately.
The tables are only linked to the JSON tables, so all the data is being pulled from that external file, and therefore can't be referenced in the query - meaning you couldn't create a table from the external JSON file.
Had another quick question for you guys... I see that you have Min, Max, Avg, and Sum functions for your columns, but I cant seem to find anything about a Count function for string datatypes. Essentially what Id like to do is have a bar above my table that contain shortcodes that show how many Tanks are in each level status. So each user can see that there is ___ tanks in the "Low" status, ___ tanks in the "Critical" status, and so on. Any idea how I can go about doing this?
Hi again Dalton
I am sorry to disappoint you, but unfortunately something like this is not possible with the plugin's built-in features.
Calculation functions can only be used on integer and float type columns.
If you need to place this above the table, on front-end, my advice is to create a separate SQL query based table, with a query similar to this:
That way, you will have two columns in that new table:
Then, you can count the SUM for that column, but it would show the total of all values from a column - in the above case 24, which is not what you want to achieve.
To achieve having a SUM for every value, you can try this query:
And the table will look like this:
Then you can calculate the for each of these columns, and use the SUM shortcode to display it on the page where the original table is:
Please note, though, that this sort of query will result in the SUM not to return the correct result, so you will need to disable server-side processing for this table.
I hope that helps.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables
Are you able to either:
SELECT
levelStatus,
COUNT(levelStatus)
FROM 'MyJSONTable'
GROUP BY levelStatus
If so, what does the syntax look like for calling an existing JSON based WPDataTable inside a SQL Query?
Hi Dalton
I'm sorry, but JSON tables are not being stored in the database, so you can't pull them using SQL queries, unfortunately.
The tables are only linked to the JSON tables, so all the data is being pulled from that external file, and therefore can't be referenced in the query - meaning you couldn't create a table from the external JSON file.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables
That's kinda what I figured, thanks for the reply!
You're welcome Dalton.
Sorry I couldn't provide a more useful response.
If you have any further questions or issues, please feel free to open a new ticket, and we'll gladly help.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables