Generate a query to count and display the number of full time and number of part time employees, the total pay of all fulltime employees and the total pay of all the part time employees.
Workings:
So I have the fields Status and Total Pay. I added the field Status and the field Status again which is a Count but it is hidden. I then added a new field called "Number of Each Status Type". I then referenced it to Status and gruped it by count.
This gave the desired first two rows of the image.
I am not sure on how to get the third though. How would I get the Total Pay by Status. Any help will be appreicated.
It has look like this
What I have for Query
Related
This is probably simple. But I’m at a standstill. I am using Coldfusion 2021 on a Windows PC. I am trying to Output data that has the sum of payments made by a couple of individuals. This sum of payments is subtracted from a goal number of $425. When one of our members make a payment of say $5 dollars one day, then $20 another day, the output would total their payments to date of $25. But I want that payment to date to subtract from the static number of $425 within the output which should be a balance of $400 and so on. But I’m getting some wacky results in my balance column whenever I cfoutput my query. Anyone have any ideas that may point me in the right direction? Below is the code that I used and Below that are two images, one shows the incorrect balance column and the other one shows my desired balance column.
[![Below is the code that I used and Below that are two images, one shows the incorrect balance column and the other one shows my desired balance column.]
Because you have a hard-coded activityCost and activityDeposit (or obtained from elsewhere), there's no need to send them to the database at all. Just get the SUM() of the payments, then in your single-row-per-group output, do the math there, like:
#activityCost - activityDeposit - expense.balance#
And expense query's "balance" column, you might rename it after removing the unnecessary values to just "payments" since that's really what you're grabbing from the database.
Your queries are more complicated than necessary. This will get your data:
select fname, lname, sum(buspayamount) as AmountPaid
from name join bustrip on name.foiid = bustrip.busfoiid
where whatever, maybe a date range
group by fname, lname
This will display it:
<table>
<tr> table headers go here
</tr>
<cfoutput query = "nameofquery">
<tr>
<td> #fname# #lname#</td>
<td>$#AmountPaid#</td>
<td>$425-#AmountPaid#</td>
closing tags
I'm trying to make a sum iif function which checks based on an employee's hire date and the ending pay period date whether they are part of the payroll period. So my idea was sum(iif([table1].[hiredate]<=[table2].[ppend],1,0))
While it works well for some, for some employees the number it gives is ridiculous. To give you an idea, there are 200 records for ppend, but it returns for some employees especially those who are well before the earliest ppend date, a number of 400 upward to 450. I'm also attempting to have it compare relative to the current date as well so I've used sum(iif(table1.hiredate<=table2.ppend<=date(),1,0)) but it largely leads to the same result. Could anybody help. Perhaps there is a factor I've neglected.
For table 1 the column data is in this order: employee ID, name, hire date and table 2 is payroll date, pp beg, pp end.
I have a table of travel expenses for analysis.
I would like to create a calculated column with a value for the maximum count of records with a certain category for each employee on any given day.
For example, if the category being reviewed is "dinner", we would like to know what is the maximum number of dinner transactions charged on any given day.
The following custom expression was able to count how many dinner expenses per employee:
count(If([Expense Type]="Dinner",[Expense Type],null)) over ([Employee])
But when trying to get the max count over days, I cant seem to get it to work. Here is the expression used:
Max(count(If([Expense Type]="Dinner",[Expense Type],null)) over ([Employee])) over (Intersect([Employee],[Transaction Date]))
This seems to provide the same answer as the first expression. Any idea on how to get this code to identify the value on the date with the most expenses for each employee?
If i understand your question and comments correctly, you should be able to use intersect.
count(If([Expense Type]="Dinner",[Expense Type],null)) over (Intersect([Transaction Date],[Employee]))
You may need to cast [Transaction Date] as a date if it is an actual DateTime. Otherwise you'd get one for each unique DT.
I created a simple report that has 5 columns (CompanyName, Bought, Sold, Returned, Total)
This is what it looks like.
CompanyName Bought Sold Returned Total
With the exception of the Company Name, every value is a number. I created simple queries for Bought, Sold and Returned. For Total I used arithmetic in the main query (basically the sum of Bought, Sold, Returned (Returned is always negative)). The problem I came across is that for some companies, some of the columns (Bought,Sold,Returned) are NULL since ex: they don't have any RETURNED so when I run the report, it doesn't show me any value for TOTAL. Unless I have values in all three(BOUGHT SOLD and RETURNED) - nothing gets displayed in TOTAL. I don't want to display any zeros in the report itself because it would be too clustered, but is there a way for me to convert the NULL to 0 only when it does the calculation and but hide it from the report?
I have a purchase table with columns - item_key, price, recorded_at(datetime).
For any item, price changes once in a while, as we run some promotional campaigns. For instance; regular price for item_key 1 is 100 and we reduce the price to 80 for a week and then go back to regular price. The promotional price could be different at different times (next time it could be 60 instead of 80). We have around 100 items.
I am trying to write a query (mysql) to fetch number of days by item by price. My query is getting way too complex and taking more than acceptable time to return results.
I would greatly appreciate any help on this.
Thanks,
I am not entirely sure what you mean by "number of days by item by price".... I assume since this is a purchase table, each entry is a purchase made... If this is the case and you want to see how many distinct days there was a purchase for each item and a certain price, I think this should work:
SELECT item_key, price, COUNT(DISTINCT recorded_at) from table
GROUP BY item_key, price
I think this should take every item_key/price pair and count how many distinct days there was a sale for that pair.