Riddhi Valecha

Riddhi Valecha

  • 421
  • 3.2k
  • 396.5k

SQL Query - Please Help

Oct 26 2016 12:41 PM

UserMaster

ID

UserName

CreatedBy

Flag

1

Ashok

Admin

1

2

Amit

Admin

1

3

Amita

Admin

1

4

Amrita

Admin

1

5

Sandhya

Admin

1

UserTransactions

ID

UserName

SerialNumber

CertifiedStatus

Certifiedon

1

Ashok

A1

1

1-JAN-2016

2

Ashok

A2

1

1-FEB-2016

3

Ashok

A3

0

3-MAR-2016

4

Amit

A4

0

1-APR-2016

5

Sandhya

A5

1

3-MAR-2016

6

Sandhya

A6

1

1-JAN-2016

7

Sandhya

A7

0

1-JAN-2016

8

Sandhya

A8

0

1-JAN-2016

9

Amit

A9

0

3-MAR-2016

10

Amit

A10

1

3-MAR-2016

Output –

There are total 5 users, out of which 3 users have entered details.

UserName

Total Transactions

Certified Status

Date

Ashok

3

True

3-MAR-2016 (Max date of transaction)

Amit

3

True

3-MAR-2016 (Max date of transaction)

Amita

0

False

Null

Amrita

0

False

Null

Sandhya

4

true

3-MAR-2016 (Max date of transaction)

UserName –

Total Transactions – total transactions made by user

Certified stauts – if number of transactions is more than 0, then true, if zero then false

Date – Max Date of transaction

Also, how to get min and max date in output variable from stored procedure in asp.net c#??

My stored procedure –

@MinDateOut varchar(max) output

Select @MinDateOut = min(t.CreatedOn) from UserTransactions t


Answers (7)