![]() | |
#11
| |||
| |||
|
|
SELECT loyalty_id FROM transactions GROUP BY loyalty_id HAVING COUNT(*)>1; From this i got loyalty_id 1 2 3 4 But i need the count, here the count(loyalty_id) is 4. how to get that with the above query..? |
#12
| ||||
| ||||
|
|
jason thank for the reply... with ur first query SELECT COUNT(DISTINCT loyalty_id) FROM transactions; i got total count of repeated values and non-repeated values. lets take an example... plz understand my question.. my loyalty_id values(1,1,1,2,3,3,4,5,5,5). with my query i got the correct output. THIS IS MY QUERY.. SELECT loyalty_id FROM transactions GROUP BY loyalty_id HAVING COUNT(*)>1; after run this query i got repeated values.It displays like loyalty_id 1 3 5 bcz this 1,3,5 are repeated values and 2,4 are non-repeated values, so i don't need that. MY PROBLEM IS, HERE DISPLAYS ALL THE REPEATED VALUES(1,3,5). BUT I NEED ONLY THE COUNT. HERE THE COUNT WILL BE 3. BECAUSE 3 VALUES REPEATING.so how to do this with my query OUTPUT WILL BE..... loyalty_id 3 |
|
SELECT * FROM TableName1; +----+------------+ id | loyalty_id | +----+------------+ 1 | 1 | 2 | 2 | 3 | 3 | 4 | 4 | 5 | 5 | 6 | 5 | 7 | 5 | 8 | 1 | 9 | 3 | 10 | 1 | +----+------------+ |
|
cnt | +-----+ 3 | 2 | 3 | +-----+ |
|
cnt_loyaltyid | +---------------+ 3 | +---------------+ |
#13
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |