Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL QUERY HELP

Author  Topic 

rahulmalhotra26
Starting Member

23 Posts

Posted - 2008-01-30 : 19:53:04
select column1,column2
from Tables
where time between 'xxxxxxxx' and 'xxxxxxxx'
and
(account+Convert(varchar,time,1)) in (select (account+Convert(varchar,time,1))
from tablename join table name
where txntime between 'xxxxxxxx' and 'xxxxxxxx'
group by dateadd(d,datediff(d,0,txntime),0),accountno, txntime
having sum(amount)>=20)

i have to goals behing this
1. To get the list of accounts that had deposits more then $X amount
2. After sorting those records getting detailed deposites

For example:
Account Number 1: $10 26th january 2008
Account Number 2: $10 26th January 2008
Account Number 1: $10 26th january 2008

what i want as an output is for accounts havin deposits more then $15 a day:

So the output i am looking for is kinda this:
Account Number 1
deposit of $20:
deposit 1 is $10 om 26th january 2008 10:42:xx:xx:XX
deposit 2 is $ 10 on 26th january 2008 14:00:xx:xx:xx
Total Deposit $20

NOTE above query would work i hope if i can get time+account but i just cant get as it gives me error for conversion.. please help guys
if i dont concatenate with time it doesnt work cauz it gives me the account numbers of the transaction but in outer query it does not compare with the amount to be $20

"I have been successful to list just the account numbers of accounts havnig more then or equal to $20, but i can not get the inner query with lists of transactions


Rahul

rahulmalhotra26
Starting Member

23 Posts

Posted - 2008-01-30 : 20:02:39
(account+Convert(varchar,time,1)) in (select (account+Convert(varchar,time,1))
I can convert time into integer i guess so that would match,, but now it says time is not in group by clause.. if i put time in group by clause the result changes please tell me a solution to that

Rahul
Go to Top of Page

pravin14u
Posting Yak Master

246 Posts

Posted - 2008-01-30 : 23:30:01
Can you give the table structure pls?
Go to Top of Page
   

- Advertisement -