March 29, 2012 at 7:05 am
Jeff Moden (3/29/2012)
Eugene Elutin (3/29/2012)
Just looking into this thread again...What I can say, crap data structure design quickly leads to crap and stupid coding you need to do to achieve something good!
Calculating VARCHARs - Plain stupid!
Can some someone come up with one good reason why would you want to store time as varchar in HH:MM format? Just one!
And don't tell me it's because of nice formatting as it it's not even that! It's not "HH:MM" it is: "#00:00" !
Verdict: REDESIGN!
Heh... calm down ol' friend. It doesn't sound good when Celko does that. What makes you think you'll sound better? I think Celko makes a real *** out of himself when he loses it like this. We've all had to deal with "crap data" before and it's usually out of our control. 😉
In my case, you are right, it IS out of my control. When I requested the creator of the table to modify the datatype, he simply said he could'nt as he had his own restrictions.
But the point is I have changed my query that does'nt at all involve what Eugene referred to. I have requirement now to SUM the time columns and then ADD them up. Anders was able to answer part of the query which works out correctly.
March 29, 2012 at 7:35 am
Are you all set then or do you still need some help to pull all of this off?
--Jeff Moden
Change is inevitable... Change for the better is not.
March 29, 2012 at 7:49 am
Thank you all for defending me...
Sorry, I wasn't right. I didn't read all posts through, what I've seen was just the first one, asking to sum HH:MM's and continues discussion about it, growing and growing from converting HH:MM back to calculable INT's to summing something UDF's. I didn't see the change of topic nature...
Would be a bit easier if OP open separate thread, but again it's my fault only of lazy-reading...
Sorry again. (the last thing I would want for myself is to be compared to J.C.:w00t:)
March 29, 2012 at 7:53 am
Jeff Moden (3/29/2012)
Are you all set then or do you still need some help to pull all of this off?
Jeff,
Actually I would need some help at this point. Anders provided a solution but I still need to SUM up the rows and then ADD up the columns.
Do you want me to point you to my query or if its possible I can create a new thread.
Thanks.
March 29, 2012 at 7:56 am
Eugene Elutin (3/29/2012)
Thank you all for defending me...Sorry, I wasn't right. I didn't read all posts through, what I've seen was just the first one, asking to sum HH:MM's and continues discussion about it, growing and growing from converting HH:MM back to calculable INT's to summing something UDF's. I didn't see the change of topic nature...
Would be a bit easier if OP open separate thread, but again it's my fault only of lazy-reading...
Sorry again. (the last thing I would want for myself is to be compared to J.C.:w00t:)
I am sorry for the harsh words too, Eugene. When you are stuck (and frustrated) on a query, the last thing you need is criticism for the wrong reasons.
March 29, 2012 at 8:17 am
pwalter83 (3/29/2012)
Jeff Moden (3/29/2012)
Are you all set then or do you still need some help to pull all of this off?Jeff,
Actually I would need some help at this point. Anders provided a solution but I still need to SUM up the rows and then ADD up the columns.
Do you want me to point you to my query or if its possible I can create a new thread.
Thanks.
I tested it and it works, you have everything you need to do what I think you need to do. But will leave it as a learning opportunity to figure out how 🙂 I will hint that the function fcn_ConvertMinutesToHours needs to be altered a little bit due to the number being too high. I get the sum of the record set given earlier to be 139 hours.
If that doesn't match what you think the result should be from the data given, then please provide the query you have.
March 30, 2012 at 2:03 am
Anders Pedersen (3/29/2012)
pwalter83 (3/29/2012)
Jeff Moden (3/29/2012)
Are you all set then or do you still need some help to pull all of this off?Jeff,
Actually I would need some help at this point. Anders provided a solution but I still need to SUM up the rows and then ADD up the columns.
Do you want me to point you to my query or if its possible I can create a new thread.
Thanks.
I tested it and it works, you have everything you need to do what I think you need to do. But will leave it as a learning opportunity to figure out how 🙂 I will hint that the function fcn_ConvertMinutesToHours needs to be altered a little bit due to the number being too high. I get the sum of the record set given earlier to be 139 hours.
If that doesn't match what you think the result should be from the data given, then please provide the query you have.
Hi Anders,
I tried to modify your code but could'nt get it to show 139 hours, its showing different weird values with an asterisk in the end something like 37.* (I am trying on a different database) and I know I am doing something wrong.
April 4, 2012 at 6:13 am
Anders Pedersen (3/29/2012)
pwalter83 (3/29/2012)
Jeff Moden (3/29/2012)
Are you all set then or do you still need some help to pull all of this off?Jeff,
Actually I would need some help at this point. Anders provided a solution but I still need to SUM up the rows and then ADD up the columns.
Do you want me to point you to my query or if its possible I can create a new thread.
Thanks.
I tested it and it works, you have everything you need to do what I think you need to do. But will leave it as a learning opportunity to figure out how 🙂 I will hint that the function fcn_ConvertMinutesToHours needs to be altered a little bit due to the number being too high. I get the sum of the record set given earlier to be 139 hours.
If that doesn't match what you think the result should be from the data given, then please provide the query you have.
Hi Anders,
Have you got any ideas on this one ? I have been trying a few things but does'nt work out correctly..
April 10, 2012 at 2:40 am
Anders Pedersen (3/29/2012)
pwalter83 (3/29/2012)
Jeff Moden (3/29/2012)
Are you all set then or do you still need some help to pull all of this off?Jeff,
Actually I would need some help at this point. Anders provided a solution but I still need to SUM up the rows and then ADD up the columns.
Do you want me to point you to my query or if its possible I can create a new thread.
Thanks.
I tested it and it works, you have everything you need to do what I think you need to do. But will leave it as a learning opportunity to figure out how 🙂 I will hint that the function fcn_ConvertMinutesToHours needs to be altered a little bit due to the number being too high. I get the sum of the record set given earlier to be 139 hours.
If that doesn't match what you think the result should be from the data given, then please provide the query you have.
Hi Anders,
I tried to amend the function as you mentioned but could'nt get it to show the sum of 139 that you got. The sum you got is correct but I am still clueless about how to bring it to that total. Could you please disclose what you changed in the function ? 🙂
April 18, 2012 at 3:27 am
Anders Pedersen (3/29/2012)
pwalter83 (3/29/2012)
Jeff Moden (3/29/2012)
Are you all set then or do you still need some help to pull all of this off?Jeff,
Actually I would need some help at this point. Anders provided a solution but I still need to SUM up the rows and then ADD up the columns.
Do you want me to point you to my query or if its possible I can create a new thread.
Thanks.
I tested it and it works, you have everything you need to do what I think you need to do. But will leave it as a learning opportunity to figure out how 🙂 I will hint that the function fcn_ConvertMinutesToHours needs to be altered a little bit due to the number being too high. I get the sum of the record set given earlier to be 139 hours.
If that doesn't match what you think the result should be from the data given, then please provide the query you have.
Hi Anders,
I am still stuck on this query, could you please let me know the amendment you did to the function ?
Thanks,
Paul
April 18, 2012 at 6:47 am
Dang it... that's the second time I lost track of this thread. My apologies. I'll try to take a look tonight.
--Jeff Moden
Change is inevitable... Change for the better is not.
April 18, 2012 at 9:12 am
Jeff Moden (4/18/2012)
Dang it... that's the second time I lost track of this thread. My apologies. I'll try to take a look tonight.
No Problem, thanks Jeff
April 22, 2012 at 10:15 am
I've been looking at this thread for a couple of days now and have decided that I don't know what the requirements are anymore. First, it start off with a column of weekly hour totals and a request for sum of the hours and further down, there's a table with weekly hours by day and no week identifier (starting date or ending date, usually). Looking at the code that you're having a problem with, I'm not even sure what the desired output should be anymore.
Can we start over on this and put all of the requirements and sample data/tables in one post along with what the output should look like so I can take a shot at it? Thanks.
--Jeff Moden
Change is inevitable... Change for the better is not.
April 23, 2012 at 2:38 am
Jeff Moden (4/22/2012)
I've been looking at this thread for a couple of days now and have decided that I don't know what the requirements are anymore. First, it start off with a column of weekly hour totals and a request for sum of the hours and further down, there's a table with weekly hours by day and no week identifier (starting date or ending date, usually). Looking at the code that you're having a problem with, I'm not even sure what the desired output should be anymore.Can we start over on this and put all of the requirements and sample data/tables in one post along with what the output should look like so I can take a shot at it? Thanks.
Thanks, Jeff !
The following fields in the table have a time datatype-
MonHours
TueHours
WedHours
ThuHours
Frihours
The requirement is to add the values for all the fields above after doing a SUM for each of them.
It should be something like this but I am not sure about the exact code and that is the reason for my query-
SUM(MonHours) + SUM(TueHours) + SUM(WedHours) + SUM(ThuHours) + SUM(Frihours).
In other words, SUM all the individual rows - MonHours, TuesHours, WedHours, ThuHours,FriHours first and then add all the resultant 5 columns.
For example, for the sample data attached, the SUM should be 174 hours (34.5 + 33 + 36.5 + 35 + 35)
It would have been easy to just SUM the Weekhours column, however, it has a varchar datatype and cant be used to SUM up the values.
I am not sure if this seems to be clear enough. Please find the table DDL and the sample data attached.
This has to be used in a report using a query so please also find the sample query attached and 2 functions that may be helpful.
Thanks,
Paul
April 25, 2012 at 2:02 am
pwalter83 (4/23/2012)
Jeff Moden (4/22/2012)
I've been looking at this thread for a couple of days now and have decided that I don't know what the requirements are anymore. First, it start off with a column of weekly hour totals and a request for sum of the hours and further down, there's a table with weekly hours by day and no week identifier (starting date or ending date, usually). Looking at the code that you're having a problem with, I'm not even sure what the desired output should be anymore.Can we start over on this and put all of the requirements and sample data/tables in one post along with what the output should look like so I can take a shot at it? Thanks.
Thanks, Jeff !
The following fields in the table have a time datatype-
MonHours
TueHours
WedHours
ThuHours
Frihours
The requirement is to add the values for all the fields above after doing a SUM for each of them.
It should be something like this but I am not sure about the exact code and that is the reason for my query-
SUM(MonHours) + SUM(TueHours) + SUM(WedHours) + SUM(ThuHours) + SUM(Frihours).
In other words, SUM all the individual rows - MonHours, TuesHours, WedHours, ThuHours,FriHours first and then add all the resultant 5 columns.
For example, for the sample data attached, the SUM should be 174 hours (34.5 + 33 + 36.5 + 35 + 35)
It would have been easy to just SUM the Weekhours column, however, it has a varchar datatype and cant be used to SUM up the values.
I am not sure if this seems to be clear enough. Please find the table DDL and the sample data attached.
This has to be used in a report using a query so please also find the sample query attached and 2 functions that may be helpful.
Thanks,
Paul
Can somebody kindly help me on this, I am stuck for quite a while now.
Thanks,
Paul
Viewing 15 posts - 31 through 45 (of 52 total)
You must be logged in to reply to this topic. Login to reply