Jump to content

SQL Help


Guest ahmed_one

Recommended Posts

Guest ahmed_one

hi,I need Help in Sql, I've a table, with following structure:*********************************************Rno RDate Code Amount101 01-07-2006 1042 3000/-102 02-07-2006 1043 4000/- 103 05-07-2006 1044 5500/-105 06-07-2006 1046 6400/-106 08-07-2006 1047 5400/-107 09-07-2006 1048 9400/-108 12-07-2006 1049 6000/-109 20-07-2006 1050 600/-*********************************************The SQL statement to retrieve Sum of Amount between 01-07-2006 and 08-07-2006 is:Select Sum(Amount) from table where RDate between '01-07-2006' and '08-07-2006'My question is, is it possible to get Sum of Amount between 01-07-2006 and 08-07-2006 AND also Sum of Amount between 09-07-2006 and 20-07-2006. Waiting for ur reply,Ahmed

Link to comment
Share on other sites

Sure man, you can do whatever you want. But it will take two queries (one for the first sum and one for the second).Select Sum(Amount) from table where RDate between '01-07-2006' and '08-07-2006'Select Sum(Amount) from table where RDate between '09-07-2006' and '20-07-2006'Is there some reason you need them both in the same query?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...