XMB Forum Software

Anyone with a good SQL knowledge ?

Mouser - 10-17-2012 at 09:36 PM

Hi all,

Don't know if this is the right spot for this, but I thought I'd try.

I'm facing an issue, that someone with some SQL knowledge can figure out just by looking at it.
I managed to receive some daily logging, and would like some statistics generated out of them.
What I managed to do... Write a VB script to;
a) Copy the logs , and extract the content (it's a compressed GZ file).
b) Create an SQL file that;
b 1) creates a seperate database-table for each (csv) log file,
b 2) import the extracted CSV file into the database-table.
c) Execute the SQL file on the MySQL-commandline.


Here is a simple representation of layout of such table (1 table per day, being called something like AB_20121010, AB_20121011, AB_20121012 <-- See how these numbers are the date YYYY MM DD)

2wobtbs.png - 7kB



Now I've been trying to figure out;

1) How to populate a table called "statistics_a" with the following information

dlqqz7.png - 3kB

2) How to populate a table called "statistics_b" with the following information

4hsg88.png - 6kB



Would be great, if this could be done in said SQL file, and not some PHP queries or something.

But I can't seem to figure it out :S


Any tips, highly appreciated.

lottos - 10-18-2012 at 08:36 AM

It would be better if you also said exactly what you are populating the two stats tables with (ie, how is the data determined), then you can look at how to do it with sql


SELECT (
SELECT COUNT(*)
FROM source_table WHERE...
) AS tot_one,
(
SELECT COUNT(*)
FROM source_table WHERE...
) AS tot_two,
(
SELECT COUNT(*)
FROM source_table WHERE...
) AS tot_three


INSERT INTO target_table(tot_one, tot_two, tot_three)

Mouser - 10-21-2012 at 09:16 PM

Thank you lottos! That gave me the right idea on how to accomplish my goal :D

lottos - 10-22-2012 at 04:48 AM

Quote: Originally posted by Mouser  
Thank you lottos! That gave me the right idea on how to accomplish my goal :D


You're very welcome, glad you obtained the results you wanted!