Showing posts with label requirement. Show all posts
Showing posts with label requirement. Show all posts

Friday, March 30, 2012

regarding datetime in asp.net

hi ,

i had textbox which is used to enter datetime . in the database, the data type is date/time. now my requirement is when the textbox is empty. i want 2 store a default value. which value is suitable for datetime.

i had given as follows

if textbox12.text = "" then

textbox12.text = 5/5/2000 ---- it is storing this value.

end if

but if i want 2 update this date means it is not supporting . if i select current date using calender it was saved as 12/30/1899.

can anyone help me.

regards

m.arunachalam

You can try
textbox12.Text = DateTime.Today

Wednesday, March 28, 2012

Regarding Aggregate conditions ..

Hai frns small help needed.

I have a table called sample and i have the following requirement. i.e i need sum(credit) group by ssn no.

One special condition is as follows:

For each distinct ssn if "flag" has the same CX value,then out of all the records with the same CX value, the highest "credit" value is added to the sum for that "ssn" and the rest are ignored.
If while adding "credit" to the sum and if "credit" value is equal to zero then "sum" value is used for summing else "credit" value is used.
Can any one help me out in trying this logic. I have tried but i could'nt able embed the conditions inbetween the Sql statetment.

Here is the query is used

select * from sample

id ssn credit flag sem
1 101 0 C9 0
2 101 4 C9 3
3 101 4.5 C9 2
4 101 3.5 C1 1
5 102 4.2 C3 3
6 103 0 C1 2

select ssn,flag,sum(case credit when 0 then sem else credit end) as sum from sam2
group by ssn,flag

ssn flag sum_val
101 C1 3.5
103 C1 2.0
102 C3 4.2
101 C9 8.5

The above output is wrong one.

Expected output

101 4.5+3.5=8.0
102 4.2
103 2.0

Any help would be appreciated

Regards,SELECT ssn
, SUM(max_credit)
FROM --MAX credit\ sem per ssn & flag
(SELECT dbo.my_table.ssn
, max_credit = MAX(CASE WHEN credit = 0 THEN sem ELSE credit END)
FROM dbo.my_table
GROUP BY dbo.my_table.ssn
, dbo.my_table.flag) AS mc
GROUP BY ssn|||Actually I think that is flawed. I don't think your sample data is comprehensive enough.|||Thanks, Here is more sample data

101 0 C9 0
101 4 C9 3
101 4.5 C9 2
101 0 C9 2
101 3.5 C1 1
101 3.5 C2 2
104 3.5 C1 3
105 3.5 C2 0
106 3.5 C3 1
107 3.5 C4 1
109 3.5 C6 4
110 3.5 C7 1

Regards,|||SELECT ssn
, SUM(case when max_credit = 0
then sem_for_max_credit
else max_credit end) as daSum
FROM (
SELECT ssn
, flag
, sem as sem_for_max_credit
, credit as max_credit
FROM daTable as T
WHERE credit =
( SELECT MAX(credit)
FROM daTable
WHERE ssn = T.ssn
AND flag = T.flag )
) AS maxes
GROUP
BY ssn|||Thanks for the help.sql

Monday, March 12, 2012

Reference previously calculated values in a table between rows

I have a requirement where I produce a number of rows in a table footer and each subsequent rows needs values calculated in the previous row. Fields in columns can be given a name and used in another column of the same row by using "=ReportItems!textbox1.Value".
Is the same thing available between rows?
Thanks for any help.You can refer to the previous value of fields (expressions) in table rows.
Try e.g.:
=Previews(Fields!abc.Value)
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"lsff" <lsff@.discussions.microsoft.com> wrote in message
news:C73A4807-BCE9-4B58-A2FC-4E894C07A30D@.microsoft.com...
> I have a requirement where I produce a number of rows in a table footer
and each subsequent rows needs values calculated in the previous row. Fields
in columns can be given a name and used in another column of the same row by
using "=ReportItems!textbox1.Value".
> Is the same thing available between rows?
> Thanks for any help.|||Sorry, I meant:
=Previous(Fields!abc.Value)
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Robert Bruckner [MSFT]" <robruc@.online.microsoft.com> wrote in message
news:uA75dBFdEHA.3148@.TK2MSFTNGP10.phx.gbl...
> You can refer to the previous value of fields (expressions) in table rows.
> Try e.g.:
> =Previews(Fields!abc.Value)
> --
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
> "lsff" <lsff@.discussions.microsoft.com> wrote in message
> news:C73A4807-BCE9-4B58-A2FC-4E894C07A30D@.microsoft.com...
> > I have a requirement where I produce a number of rows in a table footer
> and each subsequent rows needs values calculated in the previous row.
Fields
> in columns can be given a name and used in another column of the same row
by
> using "=ReportItems!textbox1.Value".
> >
> > Is the same thing available between rows?
> >
> > Thanks for any help.
>|||Robert,
This didn't do what I needed. For example, I have a field which contains a sum of different values (call it field A). In the next row, I calculate a value based on field A and another field in a different dataset (call this field B). In the third row, I want the total of Fields A and B (call this Field C). At the moment, I include in Field C the formula for field A and add to it the formula from Field B. I have a number of other rows wioth progressive additions. So you can see the formula in the fields keep on getting bigger and bigger. It would be nice to just say Field A + Field B, etc.
"Robert Bruckner [MSFT]" wrote:
> Sorry, I meant:
> =Previous(Fields!abc.Value)
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
> "Robert Bruckner [MSFT]" <robruc@.online.microsoft.com> wrote in message
> news:uA75dBFdEHA.3148@.TK2MSFTNGP10.phx.gbl...
> > You can refer to the previous value of fields (expressions) in table rows.
> > Try e.g.:
> > =Previews(Fields!abc.Value)
> >
> > --
> > This posting is provided "AS IS" with no warranties, and confers no
> rights.
> >
> >
> > "lsff" <lsff@.discussions.microsoft.com> wrote in message
> > news:C73A4807-BCE9-4B58-A2FC-4E894C07A30D@.microsoft.com...
> > > I have a requirement where I produce a number of rows in a table footer
> > and each subsequent rows needs values calculated in the previous row.
> Fields
> > in columns can be given a name and used in another column of the same row
> by
> > using "=ReportItems!textbox1.Value".
> > >
> > > Is the same thing available between rows?
> > >
> > > Thanks for any help.
> >
> >
>
>