If it is an issue (and I doubt it is, I suspect its something else) you could create a view with all of the SELECT statement you've come up with without the AND bit.
Then just export from the view using a query that is:
Ah yes, that slash after the AND doesn't actually exist, I somehow added that after my copy & paste.
FlameRobin exports a Grid to CSV natively, even though it's tab delmited, but unfortunately there's no way to schedule it to reoccur, hence why I'm using FBExport.exe, because I can't find another command line tool which I can set up in windows task scheduler to generate a comma delimited csv on a specified interval.
Effectively I'll take 15 copies of the batch file, changing the remotelocationID for each, schedule the batches to run every 15 minutes and upload to a webserver which will then provide the data to a flash chart, which will in effect update every 15 minutes.
Would you believe I don't even know what a VIEW is? Total database novice
Edit: Oh I see, right beneath triggers. I'll have a play. Does the view automatically update according to the data its referencing?
I think this might just work, but I'm stuck on something extremely simple. In the select query, after removing the "where remotelocationid = 12", where do I add the "remotelocationid" to atleast call the column so it's shown in the view?
SELECT extract(hour from hourlist.HOURVALUES) HR, COALESCE(sum(salestax * 7.66666666), 0) SALES FROM HOURLIST, (SELECT remotelocationid FROM invoice) LEFT OUTER JOIN INVOICE ON extract(HOUR from hourvalues) = EXTRACT(HOUR FROM wheninvoiced) and wheninvoiced >= 'today' group by HOURLIST.HOURVALUES order by hourlist.HOURVALUES
The above freezes/taking a very long time to execute. oops.
Edit: Come to think of it, this is going to be impossible, because the select statement is collating all the data from EVERY remotelocation, so it's not going to be able to report what data belongs to what location because it's hourly collation of all sales data?
Edit2: So perhaps the best plan of attack is to create a view for each remotelocation, remove the "and wheninvoiced >= 'today", then all I need FBexport to do is SELECT * FROM CHARTVIEW1 WHERE wheninvoiced >= 'today'. I'll try that.
I can't explain it, but this works without a view in FBExport:
"SELECT extract(hour from hourlist.HOURVALUES) HR, COALESCE(sum(salestax * 7.66666666), 0) SALES FROM HOURLIST LEFT OUTER JOIN INVOICE ON extract(HOUR from hourvalues) = EXTRACT(HOUR FROM wheninvoiced) where wheninvoiced >= 'today' and remotelocationid = 11 group by HOURLIST.HOURVALUES order by hourlist.HOURVALUES"
It only returns hours for which data exists, but after 3 days, I'll happily live with that.
This relates to my comment about where you put particular restrictions with a LEFT OUTER JOIN.
If you changed your query to this: SELECT extract(hour from hourlist.HOURVALUES) HR, COALESCE(sum(salestax * 7.66666666), 0) SALES FROM HOURLIST LEFT OUTER JOIN INVOICE ON extract(HOUR from hourvalues) = EXTRACT(HOUR FROM wheninvoiced) and wheninvoiced >= 'today' and remotelocationid = 11 group by HOURLIST.HOURVALUES order by hourlist.HOURVALUES
It'll probably give you what you want. I've moved the wheninvoiced and remotelocationid into the join. The effect is to work out the restricted set of data we're interested in then join to the list of hours we want to match against.
Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly
to your computer or smartphone by using a feed reader.