what does count(*)>2 mean?>?

Go down

what does count(*)>2 mean?>?

Post by mightyganesh on Fri Mar 19, 2010 6:42 pm

SELECT ITEM#,SUM(QTY) FROM ORD_ITEMS GROUP BY ITEM#
HAVING COUNT(*)>2;

what does this count(*)>2 mean?>?
avatar
mightyganesh

Posts : 53
Points : 92
Join date : 2010-02-26
Age : 30

View user profile http://ganeshguna.blogspot.com

Back to top Go down

Re: what does count(*)>2 mean?>?

Post by mightyganesh on Fri Mar 19, 2010 6:46 pm

SELECT * FROM ORD_ITEMS ;

ORD# ITEM# QTY
101 HW1 100
101 HW3 50
101 SW1 150
101 SW1 150
102 HW2 10
103 HW3 50
104 HW2 25
104 HW3 100
105 SW1 100

9 rows selected.

SELECT ITEM#,SUM(QTY) FROM ORD_ITEMS GROUP BY ITEM#
HAVING COUNT(*)>2;

ITEM# SUM(QTY)
HW3 200
SW1 400
avatar
mightyganesh

Posts : 53
Points : 92
Join date : 2010-02-26
Age : 30

View user profile http://ganeshguna.blogspot.com

Back to top Go down

Re: what does count(*)>2 mean?>?

Post by parwani_ravi on Fri Mar 19, 2010 6:49 pm

@mightyganesh

it returns the items which occur more than twice

parwani_ravi

Posts : 4
Points : 55
Join date : 2010-03-09
Age : 31
Location : Haldia

View user profile

Back to top Go down

Re: what does count(*)>2 mean?>?

Post by mightyganesh on Fri Mar 19, 2010 6:52 pm

YA I ALSO THOUGHT THE SAME
HW2 also appears twice in the table! so it must also be displayed! but it is not! Sad
avatar
mightyganesh

Posts : 53
Points : 92
Join date : 2010-02-26
Age : 30

View user profile http://ganeshguna.blogspot.com

Back to top Go down

Re: what does count(*)>2 mean?>?

Post by Christopher on Fri Mar 19, 2010 7:00 pm

the condition is "count(*)>2". HW2 appears only twice, it fails the condition. tatsy not displayed.
avatar
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 30

View user profile http://unixcpp.forumotion.com

Back to top Go down

Re: what does count(*)>2 mean?>?

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum