Click to See Complete Forum and Search --> : Help required to calculate the output?


roxcy
09-26-2006, 03:49 AM
Hi,
I am using .Net 2003 & Sql Server 2000.
I have created a table named BranchDetails which has BranchId,BranchName,NoOfDays.The Values are

1 Mumbai 10
2 Calcutta 175
3 Mumba1 45
4 Delhi 3

My condition says that No of days < 7, >30Days, 150 Days.

Now I want my OutPut in DataGrid as

BranchName <7 Days > 150days >30Days

Mumbai 1 - 1
Calcutta - 1 -
Delhi 1 - -

Plz Guide me to Calculate the Following using .net?

Thnks in Advance......................

abhi_viking
09-26-2006, 07:57 AM
hi,

can u elaborate what exactly you want. i didnt get this: Mumbai 1 - 1.
whats 1 ?

roxcy
09-26-2006, 09:30 AM
ok,
It is the number of occurences of the Branch in the Table.

sirpelidor
09-26-2006, 12:24 PM
My condition says that No of days < 7, >30Days, 150 Days.

Now I want my OutPut in DataGrid as

BranchName <7 Days > 150days >30Days

Mumbai 1 - 1
Calcutta - 1 -
Delhi 1 - -




hi, wouldn't that be easier if you do that at sql level (especially when you want to do bind to the datagrid)?

table structure e.g:
-BranchId ,Primary Key ,unique
-BranchName ,nvarchar ,null allowed
-NoOfDays ,int ,null not allowed
-lessThan7 ,bit ,default 0, null not allowed
-greaterThan150 ,bit ,default 0, null not allowed
-greaterThan30 ,bit ,default 0, null not allowed



then after you bind your datagrid, you will have your grid effect:
Mumbai 1 - 1
Calcutta - 1 -
Delhi 1 - -

(you can replace 1 and _ with a checkbox where 1 is being checked, _ is being unchecked)


so the only thing u need to do, is make sure when data got written to your table, you need to calucate the bit fields as well, otherwise they will default to 0.