Home News Contact Us Forum About Us Demos Products F.A.Q.
Shopping Cart
You currently have 0 items in your cart.


Recent Events
  • 31/12/2023 New Year SALE

    We are glad to announce New Year SALE. 25% discount for all our extensions. Use NY24 coupon code. Hurry up the discount is valid till 7 January.

  • 21/11/2023 BLACK FRIDAY 23 is coming

    BIG SALE, 35% discount for all our extensions. Use BF23 coupon code. Hurry up the discount is valid till 27 November.


2Checkout.com, Inc. is an authorized retailer of goods and services provided by ARI Soft. 2CheckOut




Follow us on twitter



Welcome, Guest
Please Login or Register.    Lost Password?

Help with Complicated SQL Statement
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: Help with Complicated SQL Statement
#54363
Help with Complicated SQL Statement 8 Years, 12 Months ago Karma: 0
Hi,

I am attempting to build a new table from a MySQL query in order to generate a bar chart. I am able to manage the chart fine, and the connection to the MySQL table is established fine.

My question relates to the complication in the SQL statement. I have tested this SQL fine, and it sums for me the values in Regulator1 perfectly.

SELECT Regulator1, COUNT(DISTINCT uSimID) AS Count
FROM Simulators
WHERE Regulator1 IS NOT NULL AND Regulator1 != ""
GROUP BY Regulator1
ORDER BY Regulator1

The issue is that I have more than one column where I need to check for and count the DISTINCT values for. The above SQL is for Regulator1 alone, but I also have Regulator2, Regulator3, Regulator4 and Regulator5 columns to check.

My aim is to add up all the counts of distinct values for each of the 5 columns. The table is structured this way because one record in the database can carry more than one Regulator, hence the need for 5 columns. Up to 5 can be designated in each record.

I appreciate any suggestions and am grateful that this is not really an issue with ARI DataTables and goes beyond your support obligations. I just have no ideas myself and have searched extensively for guidance.

Ken
The administrator has disabled public write access.
 
#54373
Re: Help with Complicated SQL Statement 8 Years, 12 Months ago Karma: 0
Thanks, but you can ignore this thread, I managed to find the solution by examining other SQL support sites for un-related but somewhat similar questions and selected testing.
The administrator has disabled public write access.
 
Go to topPage: 1