473,400 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

sql statement group by?

hey all,

I have a group by problem in mysql made in php code

if I have this table

table TEST

colunms:

ID
SID
email
DATE

and this data

ID SID EMAIL DATE

1 3 A@ BLA
2 3 A@ BLA
3 1 S@ BLA
4 1 S@ BLA
5 5 A@ BLA
6 1 A@ BLA
7 1 A@ BLA

and i do this query
SELECT count(*) AS C, EMAIL, SID FROM TEST
WHERE SID = SID GROUP BY email ORDER BY C DESC

i get

C EMAIL SID
2 A@ 3
2 S@ 1
1 A@ 5

BUT I WANT TO GET THIS

C EMAIL SID
2 A@ 3
2 A@ 1
2 S@ 1
1 A@ 5

i want to delete all the more then 1 email with the same SID from the table
but the group by is not correct..
anybody help?
Cheers,

D

Jul 17 '05 #1
2 1368
On 2005-07-06, <dev> <dev> wrote:
ID SID EMAIL DATE

1 3 A@ BLA
2 3 A@ BLA
3 1 S@ BLA
4 1 S@ BLA
5 5 A@ BLA
6 1 A@ BLA
7 1 A@ BLA

BUT I WANT TO GET THIS

C EMAIL SID
2 A@ 3
2 A@ 1
2 S@ 1
1 A@ 5


Untested:

SELECT COUNT(*) AS count, email, sid
FROM test
GROUO BY email, sid
--
Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be>
Jul 17 '05 #2

<dev> wrote in message
news:42***********************@dreader13.news.xs4a ll.nl...
hey all,

I have a group by problem in mysql made in php code

if I have this table

table TEST

colunms:

ID
SID
email
DATE

and this data

ID SID EMAIL DATE

1 3 A@ BLA
2 3 A@ BLA
3 1 S@ BLA
4 1 S@ BLA
5 5 A@ BLA
6 1 A@ BLA
7 1 A@ BLA

and i do this query
SELECT count(*) AS C, EMAIL, SID FROM TEST
WHERE SID = SID GROUP BY email ORDER BY C DESC

i get

C EMAIL SID
2 A@ 3
2 S@ 1
1 A@ 5

BUT I WANT TO GET THIS

C EMAIL SID
2 A@ 3
2 A@ 1
2 S@ 1
1 A@ 5

i want to delete all the more then 1 email with the same SID from the
table but the group by is not correct..
anybody help?
Cheers,

D


??
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chad Richardson | last post by:
I've always been mistified why you can't use a column alias in the group by clause (i.e. you have to re-iterate the entire expression in the group by clause after having already done it once in the...
2
by: serge | last post by:
/* This is a long post. You can paste the whole message in the SQL Query Analyzer. I have a scenario where there are records with values pointing to wrong records and I need to fix them using an...
7
by: mark | last post by:
Access 2000: I creating a report that has a record source built by the user who selects the WHERE values. An example is: SELECT * FROM CHARGELOG WHERE STDATE Between #10/27/2003# And...
2
by: robert kurz | last post by:
hallo ng, i am trying to parse a sql-statement with regular expressions. my goal is to get the parts of the statement. in my thoughts the group-functionality of the regular expressions should do...
1
by: Jean-Marc Blaise | last post by:
Hi folks, In case the SQL statement is not written properly, we sometimes get strange messages. The 2 following statements are simple inversion between order by and group by clause. We get an...
19
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without...
2
by: bhanab | last post by:
Hello, Please can someone help me with this select statement? How do I get the statement to keep the week number static? ie if there are no values then it should show up as NULL, zero or just stay...
2
by: iulian.ilea | last post by:
What is wrong int this SQL statement? select top 10 DOCInt.*, DOCDet.* , Cate.*, Arti.*, .* from DOCInt INNER JOIN DOCDet ON DOCInt.CodDoc=DOCDet.CodDoc LEFT JOIN Cate ON...
6
by: Twobridge | last post by:
I hope someone can help me out with my problem. I have found a sql statement that basically pulls all bills filed within a certain time period and the payments made on those bills with in the...
0
by: wbarona | last post by:
Hello everyone, Could you please provide me with some assistance on how to group by a SQL statement when a selected column comes from a subquery. Here is an example of the SQL statement I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.