recalculate field from datagridview

I have a datagridview in a windows form based on the following query :

select dbo.doss.behdr, dbo.doss.dosno, SUM(dbo.kbpres.uur) as SomUur, SUM(dbo.kbpres.minuut) as SomMinuut 
FROM dbo.kbpres INNER JOIN dbo.doss ON dbo.kbpres.ino = dbo.doss.ino 
WHERE (dbo.doss.behdr LIKE @cboBeheerder) 
GROUP BY dbo.doss.behdr, dbo.doss.dosno

Now, the fields uur and minuut are just integers. So it might happen uur=4 and minuut=140. Now I would like to have this in a extra column that it says 6:20:00 which is 4hours plus 140minutes (2hours 20minutes).

Can I do that in the sql query or how can I do that programmaticaly??

Answers


In line conversion for multiple rows returned...

(I typed this freehand, so you may need to do some syntax updates)

select 
   dbo.doss.behdr
,  dbo.doss.dosno
,  SUM(dbo.kbpres.uur) as SomUur
,  SUM(dbo.kbpres.minuut) as SomMinuut 
,  CAST ((SUM(dbo.kbpres.uur) + SUM(dbo.kbpres.minuut) / 60) AS Varchar(2)) + -- derives hour
   ':' + -- adds the ':'
   CAST ((SUM(dbo.kbpres.minuut) % 60) AS Varchar(2)) as [derivedColumn] -- derives the minutes

FROM 
   dbo.kbpres 
   INNER JOIN 
   dbo.doss ON dbo.kbpres.ino = dbo.doss.ino 

WHERE 
   (dbo.doss.behdr LIKE @cboBeheerder) 

GROUP BY 
   dbo.doss.behdr, dbo.doss.dosno

You can get this value in this fashion,

SELECT (4*60 + 140) / 60 as hours,  (4*60 + 140) % 60 as minutes

You can choose to append it and display as Text, or Process this as a property via code since you would have the other fields defined.


Need Your Help

collapse bookmarks by default in dita 1.8.4

pdf customization bookmarks args dita

i have a working customization, but what i cannot figure out is, how to set the bookmarks in my pdf document to 'collapsed' by default.

How can you handle an IN sub-query with LINQ to SQL?

sql linq linq-to-sql

I'm a bit stuck on this. Basically I want to do something like the following SQL query in LINQ to SQL:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.