Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Should this be done as a subquery or how else should i do this?

Status
Not open for further replies.

Rmck87

Programmer
Jul 14, 2003
182
US
I have a table with these columns in it that i need:

Time_Entry
Hours_Actual Billable_Flag Date_Start
4.0 0 7/30/2002
.25 -1 12/11/2002
8.0 -1 12/30/2002
1.5 -1 1/11/2002
6.75 0 1/11/2002
3.0 0 4/30/2002
3.25 -1 6/11/2002
8.0 0 8/30/2002
8.0 0 8/30/2002
8.0 -1 8/30/2002


Random hours, and a billable flag. The flag is based on a yes/no data type. What i want to do is:

1. Get the total amount of hours for each time period, (whenever the date_start fields are the same add up the number of actual_hours)

2. Whenever the billable flag is -1 or yes (Billable), i want to add up the hours for that, and place them on the same line as the criteria for #1.

3. Whenever the billable flag is 0 or no (NonBillable), i want to add up the hours for that, and place them on the same line as the criteria for #1, and #2.

So i should get something like this.....

Actual_Hours Billable NonBillable Date_Start
4.0 0.0 4.0 7/30/2002
0.25 0.25 0.0 12/11/2002
8.0 8.0 0.0 12/30/2002
8.25 1.5 6.75 1/11/2002
3.0 0.0 3.0 4/30/2002
3.25 3.25 0.0 6/11/2002
24.0 8.0 16.0 8/30/2002




One Ring to Rule Them All, One Ring to Find Them, One Ring to Bring Them All, and in the Darkness Bind Them.
 
You could achieve this in a crosstab query.

-Chopper


 
and how would i do that?

One Ring to Rule Them All, One Ring to Find Them, One Ring to Bring Them All, and in the Darkness Bind Them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top