473,509 Members | 3,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help rewriting this SQL syntax to get rid of doubletes

2 New Member
The SQL question I want to answer is: Get a list of the exhibitions and the number of artists in every exhibition.
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT exhibitionname, COUNT(Artist) AS antal
  2. FROM Exhibition, ExhibitionOccasion, Painting
  3. WHERE Exhibition.ExhibtionID=ExhibtionOccasion.ExhibitionID And 
  4. Painting.PaintID=ExhibitionOccasion.PaintID
  5. GROUP BY exhibitionname;
Hello :)! I need to get rid of the doublets in this SQL code. What can I add here to the SQL syntax to get tid of the doubletes. I have been looking at another solution but keep getting syntax errors when I want to change it and adapt it to the SQL syntax above. Please rewrite the code and post it here because I've been trying many times and I'm stuck. Your help is very much appreciated.
Expand|Select|Wrap|Line Numbers
  1. SELECT Count([%$##@_Alias].personalsecnumber) AS [antal subjects], Person.f_name, Person.e_name
  2. FROM [SELECT DISTINCT subjectid,personalsecnumber
  3. FROM Author INNER JOIN Paper ON Author.paperid = Paper.paperid]. AS [%$##@_Alias] INNER JOIN Person ON [%$##@_Alias].personalsecnumber= Person.personalsecnumber
  4. GROUP BY Person.f_name, Person.e_name, [%$##@_Alias].personalsecnumber;
May 3 '08 #1
1 1239
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. You have three tables listed in your SQL statement, and no JOINs - this will multiply the rows of each together (called a Cartesian product). Your WHERE clause will not fully restrict the rows you see because you only have two of the three tables filtered in the WHERE.

First step is to JOIN the tables (do this in the Access query editor by dragging a join line from one ID field to the matching ones in the table being joined). If you have relationships defined for these tables (as you should if you have designed them properly) then Access will use these relationships to create the joins for you in the Access query editor when you add the tables to the query window.

To create a total query in the query editor select View, Totals, remove any fields that you don't want to group the count on, add another field to the query and change its Group By clause to a Count, giving it a new name (which will create the Alias for you in the SQL).

It is a principle of this forum that as far as possible the work for assignment-type questions is done by the original poster of the question - we can't simply write the SQL for you. We can point you in the right direction, though. Please read the Posting Guidelines for further clarification, and in particular the FAQs on homework/assignments.

-Stewart
May 3 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
8605
by: Jon Maz | last post by:
Hi All, I am experimenting with URL Rewriting using the techniques outlined by Scott Mitchell in his article "URL Rewriting in ASP.NET"...
2
2574
by: Jon Maz | last post by:
Hi All, I've been looking into options for URL Rewriting in .net, and to be honest, I haven't seen anything that's easier than the old Classic Asp solution with an ISAPI filter redirecting to an...
3
2718
by: Michael Appelmans | last post by:
I'm trying to use a rule based URL rewrite application which uses HttpApplication.RewritePath. I keep getting "rsource not found" error in application when running on shared web host although the...
3
1159
by: Stephane | last post by:
Hi, I have a problem and I haven't found a good solution yet... I'm using Url rewriting for my message board so it's more readable to have something like mysite.com/1040/message.aspx instead...
3
4714
by: Greg Collins [Microsoft MVP] | last post by:
I have done a bit of research of Url Rewriting, but as yet have been unsuccessful at getting it to work well, and there are issues around what file types are supported and how much code you want to...
10
1299
by: not_a_commie | last post by:
I've seen studies before showing that it is better to rewrite code when more than 25% (or whatever) of the code needs to be changed. I can't seem to locate any references for that at the moment. Do...
9
628
by: Frankie | last post by:
I understand that with URL rewriting we can have a request come in for, say Page1.aspx, and rewrite it so that PageA.aspx gets served up to the user. My question (assuming the above is correct):...
5
2048
by: teddysnips | last post by:
Having upsized my client's back-end DB to SQL Server, the following query does not work ("Operation must use an updateable query"). UPDATE tblbookings INNER JOIN tblREFUNDS ON...
1
7875
Shinobi
by: Shinobi | last post by:
I am using ASP.net(c#) for my project. In my my project 2 pages are using URL rewriting method by referring this article URL Rewriting using Intelligencia UrlRewriter Example 1 - Blog Day...
0
7344
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
7412
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7069
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
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5060
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...
0
3216
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3203
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
441
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.