Need help with calc from tables

I have a table that contains query #1 and have another table
that contains a field that needs to use the result of the cfset in
another calc.
The new calc in query #2 needs to divide the Num_Checks_Trans
from query #1 by the by the Weekly_Hours_Recorded in query #2.
Can anyone help me figure this out?
<b>1.</b>
<cfquery name="QryEmployeeDetail"
datasource="NBProdReports">
SELECT TblContractInfo_SubMenuTable.User_ID,
TblContractInfo_SubMenuTable.Contract_Number,
TblContractInfo_SubMenuTable.Transaction_Type,
TblContractInfo_SubMenuTable.Num_Checks_Trans, TblTransType.Value,
TblContractInfo_SubMenuTable.Notes, TblMasterTrans.Date_Opened
from TblContractInfo_SubMenuTable, TblMasterTrans,
TblTransType
WHERE TblContractInfo_SubMenuTable.Task_Number =
TblMasterTrans.Task_Number
and TblTransType.Transaction_Type =
TblContractInfo_SubMenuTable.Transaction_Type
And TblMasterTrans.Date_Opened BETWEEN
#createODBCDate(DED_startDate)# AND #createODBCDate(DED_endDate)#
order BY TblMasterTrans.Date_Opened ASC,
TblContractInfo_SubMenuTable.User_id ASC
</cfquery>
<cfset totalTrans = 0 />
<cfloop query="QryEmployeeDetail">
<cfset totalTrans = totalTrans +
(QryEmployeeDetail.Num_Checks_Trans * QryEmployeeDetail.Value)
/></cfloop>
Text
2.
<cfquery name="QryEmployeeDetail"
datasource="NBProdReports">
SELECT TblContractInfo_SubMenuTable.User_ID,
TblContractInfo_SubMenuTable.Contract_Number,
TblContractInfo_SubMenuTable.Transaction_Type,
TblContractInfo_SubMenuTable.Num_Checks_Trans, TblTransType.Value,
TblContractInfo_SubMenuTable.Notes, TblMasterTrans.Date_Opened
from TblContractInfo_SubMenuTable, TblMasterTrans,
TblTransType
WHERE TblContractInfo_SubMenuTable.Task_Number =
TblMasterTrans.Task_Number
and TblTransType.Transaction_Type =
TblContractInfo_SubMenuTable.Transaction_Type
And TblMasterTrans.Date_Opened BETWEEN
#createODBCDate(DED_startDate)# AND #createODBCDate(DED_endDate)#
order BY TblMasterTrans.Date_Opened ASC,
TblContractInfo_SubMenuTable.User_id ASC
</cfquery>

This can be rewritten as a single query which is good for a
number of reasons, including we only make one trip to the database
and we do our calculations on the SQL backend, which is faster than
doing them in CFML.
What you're going to want to do is SUM() the total
transaction values by having a column like SUM(Num_Checks_Trans *
Value) AS totalTrans. To get the value for your other column you
can calculate that like Num_Checks_Trans / Weekly_Hours_Recorded. I
didn't see the latter in either of your queries so I'm not sure
where it comes from, but you can definitely use it in your SELECT
clause when calculating.
Since SUM() is an aggregate function, you'll have to use a
GROUP BY clause to make it work. You'll have to GROUP BY each
column in the SELECT statement. If some of the columns have
differing data that you won't want to use in the GROUP, you can
always use a nested subquery as part of your FROM clause and then
join that to the original queries with the totals.
I hope that helps.
- William

Similar Messages

  • Please i need help with switch from the us store to malaysian store how i can switch

    Please i need help with switch from the us store to malaysian store how i can switch

    Click here and follow the instructions to change the iTunes Store country.
    (82303)

  • HT1766 I need help with restore from bachup

    I NEED HELP WITH MY IPAD RESTORE FROM BACKUP

    This is the iPod touch forum and you are not providing any information to help you.

  • Need help with sum from previous years

    Hi All,
    In a report i have 4 fields. The first field shows the YTD invoice totals for the current FY 2010 (which i accomplished). The other 3 fields are :
    2nd field Sum of the value of invoices for the FY 1YEAR prior to the current year
    3rd field Sum of the value of invoices for the FY 2YEAR's prior to the current year.
    4th field Sum of the value of invoices for the FY 3YEAR's prior to the current year.
    How can i get the desired results for the second,third and the fourth fields, please need help or advice.
    Thanks

    Hi
    If you have the values for several years in the same report you should be able to do what you want using the analytic LEAD and LAG.
    LAG will retrieve values from previous rows whereas LEAD will retrieve values from following rows.
    The basic syntax is the same and look like this:
    LAG(value, offset) OVER ({optional_partition_clause} ORDER BY mandatory_order_clause)
    The ORDER BY clause is mandatory and cannot be omitted. However, this ORDER BY has nothing to do with the sort order you manually create in the worksheet. Generally, most people will set their sort order the same as the ORDER BY in the calculation.
    Here's an example that gets year to date from 2 financial years ago:
    LAG(YTD,2) OVER (ORDER BY FY)
    You have to understand that Discoverer will pull values from previous rows not from previous cells as displayed on the report, although if the cells may happen to be rows too then it will appear as though it is pulling previous cells. I personally am very experienced with analytuc functions and can make manipulate data within Discoverer just about any way that I want. Generally, if I can see data on the screen even when they are in different cells or rows I can create functions to manipulate it. This capability only comes about as a result of experience and I would strongly advise you to practice with the analytics and see if you can at least master some of them. You'll find your Discoverer capabilities will improve dramatically and you will become a great asset at work.
    When working with a new report I generally duplicate the report as a table so that I can see the values. Then if I need to sort the items in order to line up the values I want to work with I do so. Having worked out what sort order I need I can then see what offset I use then I create the analytic and use it in the main worksheet.
    Hope this helps
    Best wishes
    Michael

  • Need help with upgrade from Adobe Creative Suite to PS CS4

    My old laptop with Photoshop on it crashed and I ended up purchasing a new laptop.
    I'm trying to reload my PS CS4.  I am using an upgrade from an educational Adobe Creative Suite Premium to the CS4 and when I loaded it on my old laptop I had to get installation help through customer service, but now customer service will not help me since it is CS4.
    When installing the upgrade, it tell me to select the product I already own.  I own the educational full creative suite, but am only upgrading the Photoshop.  I chose Photoshop CS and tried entering the serial number for the suite.  It tells me that the serial number doesn't match the product chosen.  Of course the only products I'm allowed to choose from is Photoshop CS, CS2, or CS3 and not Creative Suite Premium.
    The other serial numbers on this CS is Golive CO and Pagemaker Plug-in.
    I was told there are Adobe customer service reps here on the forum, please tell me what it was I need to do to get my Photoshop installed.
    Thanks

    i wasn't aware that you could get a ps4 at an upgrade price using an older creative suite produect.  i searched online and found this thread (http://forums.adobe.com/thread/476009) which makes it appear that was not a valid upgrade path.
    but, if you're confident that was a valid upgrade path, i'm pretty sure something will need to be done on adobe's end and no amount of manipulation, on your end only, will work.
    your best bet would be to get help in this forum from an adobe staff member like jeff wright who is very knowledgeable and goes out of his way to help adobe customers.  to that end, if i were you, i would start a new thread mentioning his name in your title and in your initial post explaining:
    you have the educational Adobe Creative Suite Premium and purchased a photoshop cs4 upgrade years ago that required adobe support help to install years ago. 
    that worked well until a recent computer problem forced you buy a new laptop and you are now trying to reinstall that ps cs4 and again need support help but have been refused help because cs4 is not current.

  • Need help with adding a table-like chart

    Post Author: lindad
    CA Forum: Charts and Graphs
    I am trying to see if there is any way to add a table to a Crystal Report (using Crystal 10) that looks like a table you would create in MSWord.  We need an easy way to remove and add columns in a table and right now using drawn lines and moving fields to realign every time is a real pain.

    Post Author: lindad
    CA Forum: Charts and Graphs
    The table includes multiple rows and columns where the fields are from different places in the db.  Also, the headers are just txt fields that do not associate with a specific field. 
    If I add a border to the fields, I still need to manually move them horizontally and vertically to realign if I add or delete a column or row.  As you know in MSWord, if you add or remove a column or row in a table, the table automatically resizes itself and makes the fields line up correctly.
    Is there any way to do this in Crystal?

  • Need help with mail from pc

    I received some mail from outlook that had some odd characteristics and I'm hoping that someone can help me figure out how to get it to display normally.
    1. no header information (I don't see who the sender is, subject, etc. in Mail). The top of the message looks like this:
    ------=NextPart_000_002201C7B31B.65BC0BE0
    Content-Type: multipart/alternative;
    boundary="----=NextPart_001_002301C7B31B.65BC0BE0"
    ------=NextPart_001_002301C7B31B.65BC0BE0
    Content-Type: text/plain;
    charset="us-ascii"
    Content-Transfer-Encoding: 7bit
    2. There are embedded table in the message that in one column instead of multiple columns.
    In both cases, I can view the messages okay if I log onto the webmail server.

    I got it working i tried all the ISO files from microsoft media creation tool and none worked and i dont know why but i checked the sticker on my pc "windows 8.1 with bing" so i googled windows 8.1 with bing iso, donwloaded it and now the key worked

  • HT1296 Need help with sync from phone to computer

    When I sync my phone to my laptop, I would like info I entered on the calendar on my phone to be added to the calendar on my computer.  I can only get it to sync from computer to phone.  I need to update both
    any ideas.  I have searched the help files and can't find this anywhere

    My problem is similar. I just upgraded from the 4S to the 5 and I used to be able to sync the calendar on my iMac and iPhone using iCloud without getting duplicates by selecting/deselecting the appropriate calendars on the respective devices. Everything synced as I entered it. 
    I'm pretty sure it was working with the 5 until recently...
    Today I noticed that an event I entered on the 5 for last week didn't show up on my iMac. When I checked the EDIT screen on the phone to see what calendars were checked, only the calendar for that event was (on the All on my iPhone).  All but the Unfiled calendar are checked on the All on my iCloud.  When I unchecked and rechecked the calendars under the Phone didn't help. Can't get the thing to sync...
    Seems like most people are having problems with Exchange accts, but here I am with my iMac/Phone/Cloud...

  • Need help with query from .csv file

    I am trying to import a csv file with only 1 column in it.
    The column will only contain a 9 digit ID number. I want to read
    the file then use the contents to query a table to get the names
    and other information and display it. Here is what I have so far:
    <cffile action="read" file="#form.FiletoUpload#"
    variable="csvfile">
    <cfloop index="index" list="#csvfile#">
    <cfquery name="massimport" datasource="data1">
    SELECT * FROM IDTable
    WHERE CardNumber = ('#csvfile#')
    </cfquery>
    </cfloop>
    <cfoutput>#Name# #ID# #Site#</cfoutput>
    I get no errors but I am not getting any results. Just a
    blank page. Does anyone know how to query directly from a csv
    import? Thanks.

    You need to convert your file to a list somehow. Not sure if
    this is the most efficient way but, you can use the cfhttp tag to
    produce a query. Then your where clause becomes,
    where cardnumber in (#quotedvaluelist(query.column)#)
    and you won't need a loop.

  • Need help with paging in table layout

    Hi
    I am creating a basic table-form page with around 5000 rows in database table that needs to be displayed.
    However what i see after creating the table form page and adding detail groups i loose paging in the table layout.
    This is however undesirable.I cannot think of what is exactly making this happen there are no significant changes that i have made to the application.
    If I could know what possibly is causing the change, help would be appreciated.
    I can discuss this in detail.

    Which version of JHeadstart are you using?
    What do you mean with "i loose paging in the table layout"? Are the previous/next set and drop down list to select a range no longer displayed?
    Can you reproduce this in the HR demo applcation?
    If you remove the detail groups again, is pagination then working again.
    Steven Davelaar,
    JHeadstart team.

  • Need help with data from databases

    Hi,
    I need to search several columns in a table, for ex. the Id column and the Headline column. Of cource the id must be connected to the right headline when I want to do something to the data.
    Now I get a Resultset and I have tried out different ways to get the data out from the Resultset but the result doesn't seems to be right. Can anyone help me, please.
    -Thanks-

    You can iterate on your ResultSet if it contains several
    rows.
    Let's imagine you have defined a class Element containing
    the values you want to use.
    List l = new ArrayList();
    // Calling rs.next() put the cursor on the next row
    // and return false if there is no more row
    while (rs.next()) {
    Element e = new Element(rs.getString(1), rs.getInt(2));
    l.add(e);

  • New ipod need help with songs from old one NEED HELP!!!!

    I got a new ipod nano 3rd gen. but it wont let me take all of my old songs from my old ipod(nano 1st gen) and put them on my new one! I dont want to lose my songs so PLEASE HELP!!

    When I did that on my old ipod and it said doing so will delete all the songs on it and replace it with my library. When I did it on my new ipod it just put the songs that was already in that playlist back on the ipod, not the songs that i need from the old one.

  • I need help with programs from my MacBookAir.

    Hello. I've intalled programs on my MacbookAit that I don't need anymore and I have no idea how to remove them from my laptop. I've been a PC user and I knew there how to remove them but here I just don't know. I know that dragging them to the trash won't work. I want to remove them and free the space that is taking. I hope you guys can help me with this. Thank you Very Much!!!

    Uninstalling Software: The Basics
    Most OS X applications are completely self-contained "packages" that can be uninstalled by simply dragging the application to the Trash.  Applications may create preference files that are stored in the /Home/Library/Preferences/ folder.  Although they do nothing once you delete the associated application, they do take up some disk space.  If you want you can look for them in the above location and delete them, too.
    Some applications may install an uninstaller program that can be used to remove the application.  In some cases the uninstaller may be part of the application's installer, and is invoked by clicking on a Customize button that will appear during the install process.
    Some applications may install components in the /Home/Library/Applications Support/ folder.  You can also check there to see if the application has created a folder.  You can also delete the folder that's in the Applications Support folder.  Again, they don't do anything but take up disk space once the application is trashed.
    Some applications may install a startupitem or a Log In item.  Startupitems are usually installed in the /Library/StartupItems/ folder and less often in the /Home/Library/StartupItems/ folder.  Log In Items are set in the Accounts preferences.  Open System Preferences, click on the Accounts icon, then click on the LogIn Items tab.  Locate the item in the list for the application you want to remove and click on the "-" button to delete it from the list.
    Some software use startup daemons or agents that are a new feature of the OS.  Look for them in /Library/LaunchAgents/ and /Library/LaunchDaemons/ or in /Home/Library/LaunchAgents/.
    If an application installs any other files the best way to track them down is to do a Finder search using the application name or the developer name as the search term.  Unfortunately Spotlight will not look in certain folders by default.  You can modify Spotlight's behavior or use a third-party search utility, Easy Find, instead.  Download Easy Find at VersionTracker or MacUpdate.
    Some applications install a receipt in the /Library/Receipts/ folder.  Usually with the same name as the program or the developer.  The item generally has a ".pkg" extension.  Be sure you also delete this item as some programs use it to determine if it's already installed.
    There are many utilities that can uninstall applications.  Here is a selection:
    AppZapper 2.0.1
    AppDelete 3.2.6
    Automaton 1.50
    Hazel
    AppCleaner 2.1.0
    CleanApp
    iTrash 1.8.2
    Amnesia
    Uninstaller 1.15.1
    Spring Cleaning 11.0.1
    Look for them at VersionTracker or MacUpdate.
    For more information visit The XLab FAQs and read the FAQ on removing software.

  • New to Oracle- Need help with installation from cmd shell.

    Hello!
    I am writing a script to automate the installation of Oracle Forms and Reports 6i in XP through cmd.exe. The script works great, but the command is incomplete.
    Currently the command in the script is "setup -responseFile directory\response.rsp".
    This is supposed to generate a .rsp file containing all the options I selected in the custom installation (so I can simply call that file in future implementations of this script to automatically get all those settings), but it does not.
    Does any one know what might be wrong: why isn't this generating the response file?
    Or, do you know the arguments for the command so that I don't even need a response file?
    I've googled this about a dozen times and found nothing very helpful.
    Any advice is appreciated.
    P.S. I've also tried -record -destinationFile. No luck with that either.
    Message was edited by:
    user582111

    Madrid,
    I had already tried that with no success. Just to be sure, I tried it again a moment ago exactly as you have it written except for the location name ("setup.exe -record -destinationFile \\directory\response.rsp"). Again, I don't see a response file.
    I have viewed the link you sent me as well. Unfortunately, it looks like a I need to use the Universal Installer? I don't see anything like that in my installation directory. Am I completely missing something? Oracle is a whole new bag for me.

  • Need help with calc all command..

    Hi All,
    I have a situation where I need some of the members in accounts dim not be aggregated but some to be aggregated..
    so i used.............. calc all except mbr(mbmr_name)
    but still i see that the values for this member roll up
    can any one help me this
    thanks in advance

    With knowing all the details, I would suggest maybe creating an alternate hierarchy to provide you another look at aggregate data minus the accounts you are not wanting to aggregate. Just a thought, there are several ways to work this issue......but this is the first I would suggest looking into. If it gets more complicated, then I would explore creating calc script logic utilizing UDA's. Hope this helps.
    JC

Maybe you are looking for

  • How to suppress some lines from printing

    Dear all I have a problem of suppressing some lines in a character mode report depending on some condition. E.g. say I have 5 lines per record to be printed. Say Name, Add1, Add2, Add3, City. Now depending on a condition, I don't want to print Add2,

  • Subject: RE :(forte-users) Web enterprise & user visibleservice Objects

    A few months ago we faced a similar problem while migrating from classic Forte to Web. We had to protect our investment in various frameworks that we wrote for the classic Forte apps, which made use of extensive user-level-caching among other things.

  • Variable Wastage % based on Order Qty

    Hi All, I have a requirement to maintain a variable wastage % based on order qty for my raw-materials. For instance, in cases where the order qty < 500 the wastage should be 5%, if the order qty > 500 and < 1000 then the wastage should be 6% and so o

  • Regarding Custom IDOC Creation

    Hi All, I Am New to ABAP , Any one Please Give me the Step -By Step Procedure to create Custom IDOC. I Have this Link with me. Step by step custom IDOC creation But I Don't Know that What should i Give field names and Data elements How to create Fiel

  • Max Number of records for BAPI 'BAPI_PBSRVAPS_GETDETAIL'

    Hi All, Can you suggest me the number of records to be fed to the 'BAPI_PBSRVAPS_GETDETAIL'. I am using a few location products for 9 key figures.Whenever number of records in selection table increases BAPI behaves in a strange way and the code writt