I can do it in PHP but how with CF?

I have a sizable database that keeps track of profit per job
that goes back several years. What I need to do is create a table
layout of:
1) Customer's ID
2) Total $ from 2004
3) Total $ from 2005
3) Total $ from 2006
In PHP I do a fair amount of query sorting with arrays, but
since CF doesn't support testing an empty array element that seems
to be out.
The process I'm using is basically this: (in PHP)
SELECT SysID, ProfitAmount, Year
FROM Table
WHERE year = '2004' or year = '2005' or year = '2006'
while($row = mysql_fetch_assoc($query){
$job[$row[SysID]][$row['Year']] += $row['ProfitAmount'];
It's possibIe that a client didn't do business one year, so
potentially this can cause empty elements:
$job[1234][2004] = 100.00
$job[1234][2005] = NULL
$job[1234][2006] = 300.00
I've tried using GROUP BY in SQL as well as QofQ but I'm not
having much luck. I really want to give CF a fair shot, it seems
like it can do some impressive things, but something so simple to
do in PHP seems almost impossible to do here outside of running 4
queries, 4 QofQ (to join results) and a bunch of cfcatches so an
empty array elements won't crash the whole thing. What am I missing
here?

Quotes around the year? That's scary. In any event, if this
query:
SELECT SysID, ProfitAmount, Year as TheYear
FROM Table
WHERE year = '2004' or year = '2005' or year = '2006'
returned rows for 2004 and 2006 but not 2005, but you want to
display all 3 years, here is one way to do it. Let's call that
query q1.
<cfscript>
YearsIWant = "2004,2005,2006";
for (i = 1; i lte ListLen(YearsIWant); i = 1 + 1) {
ThisYear = ListGetAt(YearsIWant, i);
// if ThisYear is not in the query, add it.
if (ListFind(ValueList, q1.TheYear) is 0) {
x = QueryAddRow(q1, 1);
x = QuerySetCell(q1, "TheYear", ThisYear);
x= QuerySetCell(q1, "ProfitAmount", 0);
x = QuerySetCell(q1, "SysId", "something");
} // end if
} // end loop
</cfscript>
<cfquery name ="q2" dbtype = "Query">
select SysId, ProfitAmount, TheYear
from q1
order by TheYear
</cfqyuery>
Then output q2 as you see fit.

Similar Messages

  • Ok so i am trying to home share with my roommate and we have where we can see each others music but how do i get his music copied into my itunes so when we dissconnect it will still be there (working off 11.1.2

    ok so i am trying to home share with my roommate and we can see each others music but how to i put his music into my itunes so that when we dissconnet it will still be on my computer ? we are both on version 11.1.2 of itunes

    Welcome to the Apple Community.
    Select the content you wish to import and use the import button at the bottom of the screen.

  • I'm trying Facetime with my Mac Mini with OS 10.7.5 and an Acer H243HX monitor (w/ HDMI, USB). I can get the webcam-in , but even with settings in Sounds set to have the input come through the Acer monitor, I still cannot get any sound input into the Mac.

    I'm trying Facetime with my Mac Mini with OS 10.7.5 and an Acer H243HX monitor (w/ HDMI, USB). I can get the webcam-in , but even with settings in Sounds set to have the input come through the Acer monitor, I still cannot get any sound input into the Mac. Any suggestions or ideas? Thanks!

    I'm trying Facetime with my Mac Mini with OS 10.7.5 and an Acer H243HX monitor (w/ HDMI, USB). I can get the webcam-in , but even with settings in Sounds set to have the input come through the Acer monitor, I still cannot get any sound input into the Mac. Any suggestions or ideas? Thanks!

  • I can open the other website but not with twitter, there's a lock icon on the top beside the word twitter, what should i do?

    i can open the other website but not with twitter, there's a lock icon on the top beside the word twitter, what should i do?

    yes,safari
    if I add twitter to my homescreen so if I open it,the title twitter appear on the top
    but can't run,and there's a lock icon beside it,
    and I try to open tumblr too but it's can run and no lock icon besides

  • After I right-clicked on an unwanted email in Microsoft Web Access and put a filter on it all my emails and the menus disappeared. I can re-access in IE but how do I restore what I have foolishly done in Firefox?

    I was working through my emails in Microsoft Web Access when I came across an email from a sender who keeps spamming me. I right-clicked on this unwanted email, saw a filter option and (recklessly) chose it. ALL my emails and the menus disappeared. I can re-access my emails in MWA in IE but how do I restore what I have foolishly messed up in Firefox? When I get to my email page in MWA in Firefox I now see nothing but the movable vertical bar.

    You should really read the manual.
    "How do you restore from backup? "
    Restore.  When given the choice, choose to use backup.
    "And how can I check to see if the pics and videos are on my computer somewhere first??"
    They would only be where you put them.  What program did you use to import them?  Pics/vids taken with ipod are not part of the sync process at all.  You should be importing them just as you would with any digital camera.
    If you did not import them, then they are not on your computer.

  • 10.0.6 now can import MXF files.  But how??

    We have a Canon XF300 which shoots MXF files.  Up until now, we "Log and Transfer" and FCP rewraps the .mxf to be .mov files.
    Everything works perfectly!
    But I see now that 10.0.6 can work directly with these MXF files with no need to rewrap, allowing us to NOT have to rewrap to .mov  (with a 3rd party plugin?)
    BUt how do I do it?  I put the original (from the camera) CONTENTS folder (the camera's original media) on the desktop - but when I Log & Transfer, or import the media - it's still converting to .MOV!
    What am I missing here - I feel like I ought to know this!
    Thanks,
    Larry

    Hi Tom,
    Nice hearing from you.  Are you saying we would need to get 1 of the above 2 software programs?  Spending $250 to allow us to do what 10.0.6 says we can do?
    Well what did Apple do??  Sounds like the 2 software companies above are "doing" it? I thought (obviously I'm WRONG!  . . . that 10.0.6 allows direct mxf import without rewrapping. 
    So in order to take advantage of the direct MXF import (that 10.0.6 allows), we need to buy software for $250 and up??  I just want to make sure I'm understanding this?  Thanks very much for your input.
    Larry
    Thanks very much.

  • Can I use iMovie 09 but stay with iPhoto 08???

    Hello,
    QUESTION: Can I install iLife '09 but still keep iPhoto '08 and use iPhoto '08 instead of iPhoto '09 but use the other iLife '09 programs??
    BACKGROUND: I am installing Leopard (after much delay...) and I believe iMovie '09 (part of iLife '09) has a timeline and more features (vs iMovie '08) plus easier to use etc. So I think I want to make my first projects with my 8 hours of vacation videos via my Canon FS100 using iMovie 09 - can put in chapters and such, too I believe.
    BUT in trialing iPhoto 09 on another computer, I see that for now at least, I don't want the geographic info / the faces etc. and kinda prefer to stay with iPhoto '08 for now with my 25,000 photos over the past 5 years...
    *Is that possible to do?-*
    Thanks for any comments--
    Regards,
    Steve
    Friday 20 February 2009

    Thanks for the fast and informative reply!
    1. iPhoto 09: This converts all the iPhoto Library photos to another format not recognized by iPhoto 08. OK I have several copies on several LaCie external HD's - but I'm wondering if my 30 gb 2008 iPhoto library will now turn into 50 gb in iPhoto 09???
    2. Speed: I've been afraid that on my 3 year old MB iPhoto 09 may run much slower than iPhoto '08. You say not much performance hit - but I enjoy fast-- and next Mac (will that be #15 in 20 years?!- at least!!) likely to be a MB Pro - or maybe the fastest desktop I can afford?!?
    3. I'm not using FaceBook / Flickr at this time - just MobileMe
    iMovie 09: I hope one can insert chapters! Would not want to have to go via HDiMovie06 / garageband to do this-- hey, I've got everything downloaded, but haven't made a single movie / DVD yet! Really I'd like to just get about an hour or two of my 8 hours onto a DVD that looks OK - for a first "YES!" - would you say iMovie '09 is going to be easier to "master" than 08?
    Thanks very much!! -- and if anyone can let me know if iPhoto 08 / iPhoto 09 can exist together - and if so, how to do this during installation - cuz it seems iPhoto 09 deletes previous iPhotos...
    Steve

  • I can send vars to php but not load

    My AS2 script:
    var sen = new LoadVars();
    sen.nam = "mycont";
    sen.wor = "test";
    myvar = sen.wor;
    And I got a button with the script:
    on (release){
    _root.sen.sendAndLoad("this.php", _root.sen, "POST");
    And a textbox with the var "myvar".
    My PHP content is:
    <?php
    $myf = "that.html";
    $cont = $_POST['nam'];
    $write = fopen($myf,"w+");
    $wor = fread($write, filesize($myf));
    $vars = "wor=" . $wor ;
    echo $vars;
    fwrite($write, $cont);
    fclose($write);
    ?>
    When running it the send is succesfull because I can see that
    it edits my file.
    But nothing is get into my textbox.
    Whan is the problem? I try to fix it two hours already.
    Thank yo for your help...

    well, first myvar is going to have a value of "test", but
    that doesn't mean anything's been received from your php file
    because you're assigned rec to have a property of wor that has a
    value of "test".
    if you're not seeing that, you have a problem that has
    nothing to do with your php file: you don't have a visible
    textfield that has variable myvar.
    second, you don't want to assign any properties to rec. you
    want those properties to be assigned by your php file so you can
    retrieve feedback from your script, including assurance that it
    executed properly.
    further, you don't want to use the code i showed. i
    mistakenly thought you wanted to send wor and its value to your php
    script but there's no reason for that. so remove that
    sen.wor="test" line of code.
    finally, you probably don't have a way to check the trace()
    functions output so you can't see if everything is working. instead
    of using trace(src), use myvar=src and make sure myvar is an
    existing visiable textfield variable. (or, even better, use a
    textfield instance name and assign its text property.)

  • Canon LPB2900 - It can work on a Mac, but how?

    I have read various threads that suggest this Canon laser can be forced to work under OS X 10.5, but despite downloading CAPT files and unzipping various work rounds, I am having no luck at all. This is probably because I am more familiar with Windows- I forced this printer to work with Vista when the driver was only for XP until Canon got around to updating it.
    Any tips or ideas welcome - but please treat me like an idiot. I need my hand holding!
    (MacBook Pro - late 2008)

    As is often the case, I found a solution by reading back in this forum - in my defence I missed the answer several times. I also remembered to paste bits in the correct place.

  • Well i can load Class from file, but how i save it to file?

    Hello,
    Let's say we can load some Class using ClassLoader, but if i want to do the opposite? I would like to make a .class file, for this i have got Class object and few methods.
    the start would look like this;
    Class<?> cl = ....;
    String nameWithPackages = cl.getName().replaceAll("\\.", "/")+".class"
    File file = new File(nameWithPackages);
    ... Well now i need to fill the class file with the data, any ideas?
    Thanks
    Juraj

    morgalr wrote:
    Don't use a class file for data, use a JAR or ZIP.I mean it's data - the bytecode of the class, but not sure where i get the it, because there isn't any method like that in Class.
    To better explain it lets say i got class
    public class SomeClass {
    }Let's say i got the SomeClass
    Class<?> thisIsSomeClass = ...; //
    //now i want to make file SomeClass.class so i can use this class later
    ...Edited by: Juraj on Jul 31, 2010 10:11 AM

  • If i can upgrade my harddrive to an ssd on a 2011 macbook pro, would i have to re-download or re-purchase my movies/music all over again? or would icloud help? i heard you can re-download them back but how?

    hello, i'm here to ask about my worries about wasting more money on re-downloading my favorite movies back on to my macbook 2011 model, because in a few weeks time, I'm upgrading to an durable SSD drive but my music/movies are at stake, so should i be safe with icloud as long as i have my itunes account? please respond back asap! my email [email protected] to be sure

    the clone won't take you that long - i cloned a 30GB drive in 20 minutes.
    here are the steps:
    first get yourself a usb external enclosure...install your new drive there....
    then download carbon copy cloner.
    now connect your external to your macbook's usb.
    launch disk utility - format/erase your new drive to mac os extended journaled.
    close disk utility and launch carbon copy cloner.
    clone your old drive - to your new drive - you will get a pop up saying that a recovery partition wasn't created.
    create one with carbon copy - proceed with the clone.  once the clone is done, turn your macbook off.
    install new drive in your macbook and install old drive to your usb enclosure - use it for back up purposes.
    turn your macbook back on - if boot time takes longer than 45 secs - go to system preferences - startup disk - select your new drive as the startup drive - restart your macbook.
    now it should boot at 14 sec.
    it's that simple

  • Can't connect via Finder but works with everything else

    The Time Capsule is working fine with Time Machine and Airport.  However when I try to connect via Finder, it just says 'Connecting...' and never changes.  When I hit 'Connect As...', nothing happens.  I have rebooted the TC and deleted all passwords from the keychain but that didnt help.  Latest OSX updates and firmware update installed.

    I powered down and was relieved to hear the fan jolt and the drive spin so that looks good.
    Wireless is currently the only method I've been using to connect to the TC with my macbook because as of right now I dont have a USB->ethernet adapter but I will pick one up later today to see if that changes anything.  The cable modem is connected via ethernet though and that seems to be working fine.
    The LED is solid green when the modem is plugged in and flashing orange when it is not.
    Here is the log after a power cycle, at first I did not have the cable modem plugged in and attempted to access via Finder with no luck. Then shortly after, I plugged in the cable modem and tried Finder again. Its interesting that attempting to access the drive via Finder does not create any activity in the log. 
    I will try to cool down overnight and hope I can get at the data.  At this point, my main goal is to retrieve the files.  And then get a new local backup solution asap.  I am currently doing a full online backup to Crashplan but with 500GBs, its going to be weeks before it finishes uploading. 
    Jul 13 05:47:42
    Severity:5
    Initialized (firmware 7.5.2).
    Jul 13 05:47:54
    Severity:5
    Deauthenticating with station ff:ff:ff:ff:ff:ff (reserved 3).
    Jul 13 05:47:54
    Severity:5
    Deauthenticating with station ff:ff:ff:ff:ff:ff (reserved 2).
    Jul 13 05:47:54
    Severity:5
    Rotated CCMP group key.
    Jul 13 05:48:12
    Severity:5
    Associated with station 14:10:9f:d5:8e:bb
    Jul 13 05:48:12
    Severity:5
    Installed unicast CCMP key for supplicant 14:10:9f:d5:8e:bb
    Jul 13 05:48:13
    Severity:5
    Binding added for udp, 0.0.0.0:32769 to 10.0.1.3:5353 with lifetime 7200
    Jul 13 05:48:23
    Severity:5
    Connection accepted from [fe80::1610:9fff:fed5:8ebb%bridge0]:50904.
    Jul 13 05:48:26
    Severity:5
    Connection accepted from [fe80::1610:9fff:fed5:8ebb%bridge0]:50905.
    Jul 13 05:48:42
    Severity:5
    Connection accepted from [fe80::1610:9fff:fed5:8ebb%bridge0]:50906.
    Jul 13 05:48:44
    Severity:5
    Connection accepted from [fe80::1610:9fff:fed5:8ebb%bridge0]:50907.
    Jul 13 05:48:44
    Severity:5
    Connection accepted from [fe80::1610:9fff:fed5:8ebb%bridge0]:50908.
    Jul 13 05:49:36
    Severity:5
    (WAN) link state is Up.
    Jul 13 05:49:36
    Severity:5
    Internet configuration leased [IPv4] -- host <69.204.228.249/255.255.254.0> gateway <69.204.228.1> dns <209.18.47.61 209.18.47.62> wins <> lease <43200> domain <nyc.rr.com>
    Jul 13 05:49:36
    Severity:5
    Binding added for udp, 69.204.228.249:32769 to 10.0.1.3:5353 with lifetime 7200
    Jul 13 05:49:38
    Severity:5
    Internet configuration leased [IPv6] -- host <2604:2000:ffc0:27:5c41:d64:1455:8715> dns <> delegated <>
    Jul 13 05:49:38
    Severity:5
    Internet configuration leased [IPv6] -- host <> dns <> delegated <2604:2000:1009:c07c::/64>
    Jul 13 05:49:38
    Severity:5
    IPv6 route advertised [flags=ADDRESS DNS=NONE]
    Jul 13 05:49:39
    Severity:5
    Clock synchronized to network time server time.apple.com (adjusted +6 seconds).
    Jul 13 05:49:42
    Severity:5
    Binding added for udp, 69.204.228.249:32769 to 10.0.1.3:5353 with lifetime 7200
    Jul 13 05:49:51
    Severity:5
    Internet configuration leased [IPv4] -- host <69.204.228.249/255.255.254.0> gateway <69.204.228.1> dns <209.18.47.61 209.18.47.62> wins <> lease <43186> domain <nyc.rr.com>
    Jul 13 05:49:51
    Severity:5
    Binding added for udp, 69.204.228.249:32769 to 10.0.1.3:5353 with lifetime 7200

  • Can read TEDS in MAX but not with DAQmx VIs

    Hi,
    I have a cdaq 9181 with a 9234 accelerometer module.  I have 3 teds equipped accelerometers connected to ai0, ai1, and ai2 repectively.  In MAX, when I reserve the chassis I can read all three teds, no errors.  When I do the same thing in labview (ie reserve the chassis, create a daqmx task, associate teds data with each physical channel, all with daqmx VIs) I can only read two out of three teds.  The third one throws a "no teds sensor detected" error.  This code has been in use for about four months now, though I just rewrote the calling VIs, and hasn't displayed this problem.  I've attached a snippet of the task building VI for reference.
    Any ideas what's going on?
    Thanks.
    Using LV2012 and MAX 5.3.1 running on Windows 7 32 bit.
    CLAD
    Attachments:
    Build Daq Task Snippet.png ‏58 KB

    Nope.  That's a delete from array, length 1, index 3.
    In any case, I eliminated that block since the string array wired to the for loop controls how many devices the VI attempts to configure.  Same result, verified it was trying to configure ai2.  Here's the updated snippet:
    CLAD
    Attachments:
    Build Daq Task Snippet v2.png ‏54 KB

  • IMac can't share via Samba but works with AFP

    I have a home network with (almost) all Macs. Every computer shows up in the shared folder, but for some reason my iMac can't be connected to via Samba (error -36). It can be connected to via AFP.
    The iMac CAN connect to other computers via samba though.
    The reason I need samba to work is because I have a network streamer connected to my TV and it does not use AFP. I have successfully connected a ibook G4 to the streamer so basically once the iMac works on the network I think my problems are solved.
    Message was edited by: igbee

    This is solved. I believe when I upgraded from Leopard to Snow Leopard my netbios name was reset and allowed the Samba share to be accessed.

  • Keeps crashing on start up! Can start without core audio, but crashes with!

    Hello
    I've run into a strange problem, when starting Logic it keeps on crashing after core audio initialize. I have tried starting whilst holding control to select start without core audio. This works and the app starts, i then go to audio preferences to select a audio driver to use. This is the strange bit i think?
    It only gives me my audio input options, Built MIC, Built Input/ Built Input Aggregated. It does not give me an output option. I recall this not being normal? I am right or wrong here?
    I also have a motu 828 which when connected and selected also crashes the program. It was all working fine one day and not the other, i have tried a reinstall twice also. I have no idea of what is happening so any insight and help would be great.

    I have finally solved the problem. Do not use melodyne with LOGIC 8 it will not work! To run both on the same machine the melodyne rewire files must be removed from application support.

Maybe you are looking for

  • VBA: How do I add a shortcut to an email into the body of an appointment

    Dear all, I want to write a macro for outlook that lets me do the following: 1. Move a selected email to a specific folder (with selection box) 2. create an appointment in a non default calendar with the same subject as the email 3. Put a link into t

  • Merge components into new media file

    This is probably not the right place for this given this forum is around front end code mostly but I have been pulling my hair out trying to find the right solution and I am hoping some of you will have had a similar requirement given what the framew

  • Daily report

    hi exprt i want per day wise end user report in sap standard (sap user wise) for daily activity in sap account posting

  • Not able to create Lead from IC agent role

    Hi Experts, I am finding an strange problem while creating lead.I am uisng CRM2007. I am able to create Lead with Business Role as Marketing Professional, but not able to create the Lead with IC agent buisness role. I had created a new Transaction ty

  • No document found

    Have a user who gets message "document not found ", document is found by other signatories ??