I need help to work out how to do the following tasks. Can anyone help me to complete this and how?
1.The following Consumers Table in a database has the following structure
Title FirstName LastName RegDate
Ms Alethia Foster 17/04/2003
Mr Ken Noble 21/06/2003
Mr Wilfred Morris 03/01/2003
Mr Horace Morgan 02/12/2002
Mrs Heather Robertson 11/04/2003
Miss Wendy Charman 12/10/2003
Ms Lorna Jones 10/08/2003
Ms Edith Terresfield 02/05/2003
Mrs Anne Walters 02/11/2003
...
Make a single SQL query returning the registrations breakdown in the following form
ASP is Active Server Pages and 0-6 is period of months.!! So if u have any idea how i can go about the SQL query or anything with this problem, please let me know.
select * from
(
select'0-6 month' 'period of reg','total' 'gender',count(1) 'count' from dbatest where datepart(mm,regdate) >0 and datepart(mm,regdate) <7
union
select'0-6 month' 'period of reg','Female' 'gender',count(1) 'count' from dbatest where datepart(mm,regdate) >0 and datepart(mm,regdate) <7 and
upper(title) in ('MS','MRS','MISS')
union
select'0-6 month' 'period of reg','Male' 'gender',count(1) 'count' from dbatest where datepart(mm,regdate) >0 and datepart(mm,regdate) <7 and
upper(title) in ('MR')
union
select'7-12 month' 'period of reg','total' 'gender',count(1) 'count' from dbatest where datepart(mm,regdate) >6 and datepart(mm,regdate) <=12
union
select'7-12 month' 'period of reg','Female' 'gender',count(1) 'count' from dbatest where datepart(mm,regdate) >6 and datepart(mm,regdate) <=12 and
upper(title) in ('MS','MRS','MISS')
union
select'7-12 month' 'period of reg','Male' 'gender',count(1) 'count' from dbatest where datepart(mm,regdate) >6 and datepart(mm,regdate) <=12 and
upper(title) in ('MR')
union
select'1-12 month' 'period of reg','Male' 'gender',count(1) 'count' from dbatest WHERE upper(title) in ('MR')
union
select'1-12 month' 'period of reg','Female' 'gender',count(1) 'count' from dbatest WHERE upper(title) in ('MS','MISS','MRS')
union
select'1-12 month' 'period of reg','Total' 'gender',count(1) 'count' from dbatest)
sam
order by 'preiod of reg'
Bookmarks