-
Hiiii,I want to display total count of rows at webinter face.
My question is,
I have 5 columns in my table
1)Advid ------primary key
2)advtisetype---------------we can enter "wanted or forsale"
3)newentries------anynew entry.
4)advdate------ is advtisementdate
5)userid------foreign key column from other table
In my webportal i need to display total newentries weekly count only,but in case of advtisementtype ,i like to display total count of forsale and wanted.
In my portal output like--
FORSALE 30 ---(TOTALCOUNT)
WANTED 50 --(TOTALCOUNT)
NEWENTRIES 5 ---- (TOTALCOUNT WEEKLONLY)
I am not geting mixed query of out put as shown above.
thanks
kavitha
kavitha
-
Code:
SELECT advtisetype, COUNT(*)
FROM mytable
WHERE advdate BETWEEN date1 AND date2
GROUP BY advtisetype
UNION
SELECT 'NEWENTRIES' , COUNT(*)
FROM mytable
WHERE advdate BETWEEN date1 AND date2
and newentries IS NOT NULL;
Assuming that newentries column is NULL if its not a new entry. Or if it is a flag then change the where condition.
Sanjay
-
kavithared you dont have to duplicate your efforst in two forums
closing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|