SQL Experts - need help

Thread Tools
 
Search this Thread
 
Old Mar 5, 2009 | 02:07 PM
  #1  
goldfishhh's Avatar
Thread Starter
AudiWorld Super User
 
Joined: Apr 2003
Posts: 3,931
Likes: 0
From: Current: 2005 Volvo XC90 & 1996 Corsica
Default SQL Experts - need help

Here is my SQL Query in Access:

SELECT [Alljobs In Zeke].ID, [Alljobs In Zeke].Name, Occurs.YearlyFrequency, Left([Alljobs In Zeke]!Name,2) AS AppPrefix, ProdJobABEND.DATE, ProdJobABEND.ID, IIf(ProdJobABEND!DATE>=#1/1/2008# And ProdJobABEND!DATE<=#1/30/2008#,Count(ProdJobABEND!ID),0) AS [Count Jan 2008], IIf(ProdJobABEND!DATE>=#2/1/2008# And ProdJobABEND!DATE<=#2/29/2008#,Count(ProdJobABEND!ID),0) AS [Count Feb 2008], IIf(ProdJobABEND!DATE>=#3/1/2008# And ProdJobABEND!DATE<=#3/31/2008#,Count(ProdJobABEND!ID),0) AS [Count Mar 2008], IIf(ProdJobABEND!DATE>=#4/1/2008# And ProdJobABEND!DATE<=#4/30/2008#,Count(ProdJobABEND!ID),0) AS [Count Apr 2008], IIf(ProdJobABEND!DATE>=#5/1/2008# And ProdJobABEND!DATE<=#5/31/2008#,Count(ProdJobABEND!ID),0) AS [Count May 2008], IIf([ProdJobABEND]![DATE]>=#6/1/2008# And [ProdJobABEND]![DATE]<=#6/30/2008#,Count([ProdJobABEND]![ID]),0) AS [Count Jun 2008], IIf([ProdJobABEND]![DATE]>=#7/1/2008# And [ProdJobABEND]![DATE]<=#7/31/2008#,Count([ProdJobABEND]![ID]),0) AS [Count Jul 2008], IIf([ProdJobABEND]![DATE]>=#8/1/2008# And [ProdJobABEND]![DATE]<=#8/31/2008#,Count([ProdJobABEND]![ID]),0) AS [Count Aug 2008], IIf([ProdJobABEND]![DATE]>=#9/1/2008# And [ProdJobABEND]![DATE]<=#9/30/2008#,Count([ProdJobABEND]![ID]),0) AS [Count Sep 2008], IIf([ProdJobABEND]![DATE]>=#10/1/2008# And [ProdJobABEND]![DATE]<=#10/31/2008#,Count([ProdJobABEND]![ID]),0) AS [Count Oct 2008]
FROM ([Alljobs In Zeke] LEFT JOIN ProdJobABEND ON [Alljobs In Zeke].Name = ProdJobABEND.JOB) LEFT JOIN Occurs ON [Alljobs In Zeke].Occurs = Occurs.Occurs
GROUP BY [Alljobs In Zeke].ID, [Alljobs In Zeke].Name, Occurs.YearlyFrequency, Left([Alljobs In Zeke]!Name,2), ProdJobABEND.DATE, ProdJobABEND.ID;

The problem is, in the first column, the [Alljobs In Zeke].ID is duplicated for each time the count in one of the month columns is 1 or higher.

Any idea?
Reply
Old Mar 5, 2009 | 04:38 PM
  #2  
waxio's Avatar
AudiWorld Senior Member
 
Joined: Jul 2004
Posts: 662
Likes: 0
From: Palatine, IL
Default

Im not a SQL expert but I will help you... Let me send this to my friend..
Reply
Old Mar 5, 2009 | 04:40 PM
  #3  
goldfishhh's Avatar
Thread Starter
AudiWorld Super User
 
Joined: Apr 2003
Posts: 3,931
Likes: 0
From: Current: 2005 Volvo XC90 & 1996 Corsica
Default

Cool - I think I need a SELECT DISTINCT (can't recall the syntax)
Reply
Old Mar 5, 2009 | 05:05 PM
  #4  
waxio's Avatar
AudiWorld Senior Member
 
Joined: Jul 2004
Posts: 662
Likes: 0
From: Palatine, IL
Default Re: Cool - I think I need a SELECT DISTINCT (can't recall the syntax)

and you may be right. Hold on, he is trying to help you He is looking for logic behind this...
Reply
Old Mar 5, 2009 | 05:12 PM
  #5  
waxio's Avatar
AudiWorld Senior Member
 
Joined: Jul 2004
Posts: 662
Likes: 0
From: Palatine, IL
Default test this one....

SELECT [Alljobs In Zeke].ID, [Alljobs In Zeke].Name, Occurs.YearlyFrequency, Left([Alljobs In Zeke]!Name,2) AS AppPrefix, ProdJobABEND.DATE, ProdJobABEND.ID, IIf(ProdJobABEND!DATE>=#1/1/2008# And ProdJobABEND!DATE<=#1/30/2008#,Count(ProdJobABEND!ID),0) AS [Count Jan 2008], IIf(ProdJobABEND!DATE>=#2/1/2008# And ProdJobABEND!DATE<=#2/29/2008#,Count(ProdJobABEND!ID),0) AS [Count Feb 2008], IIf(ProdJobABEND!DATE>=#3/1/2008# And ProdJobABEND!DATE<=#3/31/2008#,Count(ProdJobABEND!ID),0) AS [Count Mar 2008], IIf(ProdJobABEND!DATE>=#4/1/2008# And ProdJobABEND!DATE<=#4/30/2008#,Count(ProdJobABEND!ID),0) AS [Count Apr 2008], IIf(ProdJobABEND!DATE>=#5/1/2008# And ProdJobABEND!DATE<=#5/31/2008#,Count(ProdJobABEND!ID),0) AS [Count May 2008], IIf([ProdJobABEND]![DATE]>=#6/1/2008# And [ProdJobABEND]![DATE]<=#6/30/2008#,Count([ProdJobABEND]![ID]),0) AS [Count Jun 2008], IIf([ProdJobABEND]![DATE]>=#7/1/2008# And [ProdJobABEND]![DATE]<=#7/31/2008#,Count([ProdJobABEND]![ID]),0) AS [Count Jul 2008], IIf([ProdJobABEND]![DATE]>=#8/1/2008# And [ProdJobABEND]![DATE]<=#8/31/2008#,Count([ProdJobABEND]![ID]),0) AS [Count Aug 2008], IIf([ProdJobABEND]![DATE]>=#9/1/2008# And [ProdJobABEND]![DATE]<=#9/30/2008#,Count([ProdJobABEND]![ID]),0) AS [Count Sep 2008], IIf([ProdJobABEND]![DATE]>=#10/1/2008# And [ProdJobABEND]![DATE]<=#10/31/2008#,Count([ProdJobABEND]![ID]),0) AS [Count Oct 2008]
FROM [Alljobs In Zeke], ProdJobABEND, Occurs
WHERE [Alljobs In Zeke].Name = ProdJobABEND.JOB
AND [Alljobs In Zeke].Occurs = Occurs.Occurs

GROUP BY [Alljobs In Zeke].ID, [Alljobs In Zeke].Name, Occurs.YearlyFrequency, Left([Alljobs In Zeke]!Name,2), ProdJobABEND.DATE, ProdJobABEND.ID;
Reply
Old Mar 5, 2009 | 05:17 PM
  #6  
waxio's Avatar
AudiWorld Senior Member
 
Joined: Jul 2004
Posts: 662
Likes: 0
From: Palatine, IL
Default you have to have a certain reason...

to use LEFT JOIN. I am not saying you didn't have to, because I don't know your clear goal what to retrieve from the tables.

What was modified:
"all LEFT JOIN ON" were replaced with typical "WHERE" clause.

Let me know if that help
Reply
Old Mar 5, 2009 | 06:53 PM
  #7  
JustAdam's Avatar
AudiWorld Super User
 
Joined: Aug 2004
Posts: 10,012
Likes: 1
Default OMG - this is so easy ..... all you have to do is

hire an SQL person to help you, check out Craigslist - LOL

Hope you find your solution buddy!
Reply
Old Mar 6, 2009 | 02:39 AM
  #8  
goldfishhh's Avatar
Thread Starter
AudiWorld Super User
 
Joined: Apr 2003
Posts: 3,931
Likes: 0
From: Current: 2005 Volvo XC90 & 1996 Corsica
Default Little more info....

[All Jobs in Zeke].NAME may or maynot exist within [ProdJobAbend].JOB, therefore the LEFT JOIN from All [All Jobs in Zeke].NAME -=> [ProdJobAbend].JOB and the other LEFT JOIN Occurs ON [Alljobs In Zeke].Occurs = Occurs.Occurs is there so I can display the value for the Occurs vs. the text value. The data is still displaying like this:

ID, AllJob.NAME, CountJan, CountFeb......
10,blah,0,0
11,blah1,0,1
11,blah1,1,0
.
.
.

I'm thinking of jumping right into the reporting tool (not a chance will I use Access's reporting tool - tis a joke) and see if I can group by AppPrefix then do sum for each month.
Reply
AudiWorld Stories

Bringing Audi to Life for Audi Fans

story-0

The Highs & Lows of Every Audi C-Class Generation

 Joe Kucinski
story-1

Top 10 Most Expensive Audis Ever Sold on Bring-A-Trailer

 Brett Foote
story-2

10 Audi Features & Options We Miss the Most!

 Joe Kucinski
story-3

Audi Recreates Crazy-Looking Speed Record Breaker From 1935

 Verdad Gallardo
story-4

Coachbuilder Recreates the 1995 Audi TTS Concept

 Verdad Gallardo
story-5

Every Audi V10 Car Ranked!

 Joe Kucinski
story-6

9 Audi Designs That Aged Like Fine Wine

 Verdad Gallardo
story-7

2026 Audi Q5 Buyer's Guide (Every Model Explained)

 Brett Foote
story-8

Ranking Every Current Audi 'S' Model From Worst to First!

 Joe Kucinski
story-9

10 Best Audis That are FINALLY LEGAL to Import to the U.S.!

 Joe Kucinski
Old Mar 6, 2009 | 09:33 AM
  #9  
gregmag's Avatar
AudiWorld Senior Member
 
Joined: Feb 2004
Posts: 757
Likes: 0
Default

But make sure he/she's not a prostitute or Dart will be on your ***.
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
PersianPower
A4 (B7 Platform) Discussion
0
May 31, 2006 11:20 PM
Mr. Head
Florida Discussion
0
Feb 26, 2005 06:57 AM
STASIK_A4
S4 / RS4 (B5 Platform) Discussion
0
Jul 2, 2003 05:49 PM
eskay
S4 / RS4 (B5 Platform) Discussion
1
Feb 4, 2002 04:16 PM




All times are GMT -8. The time now is 10:20 PM.

story-0
The Highs & Lows of Every Audi C-Class Generation

Slideshow: The highs and lows of every Audi C-Class generation.

By Joe Kucinski | 2026-05-27 16:05:50


VIEW MORE
story-1
Top 10 Most Expensive Audis Ever Sold on Bring-A-Trailer

People were more than happy to shell out big bucks for these cars.

By Brett Foote | 2026-05-27 15:32:23


VIEW MORE
story-2
10 Audi Features & Options We Miss the Most!

Slideshow: 10 Audi features and options we miss the most.

By Joe Kucinski | 2026-05-12 19:33:47


VIEW MORE
story-3
Audi Recreates Crazy-Looking Speed Record Breaker From 1935

Slideshow: Audi has recreated one of the wildest machines of the pre-war speed-record era, reviving a streamlined V16 racer that originally exceeded 200 mph in 1935.

By Verdad Gallardo | 2026-05-11 09:49:34


VIEW MORE
story-4
Coachbuilder Recreates the 1995 Audi TTS Concept

Slideshow: A Dutch coachbuilder has reimagined the original Audi TT by finishing what the 1995 concept only hinted at.

By Verdad Gallardo | 2026-05-05 15:17:58


VIEW MORE
story-5
Every Audi V10 Car Ranked!

Slideshow: Ranking every Audi V10 road car

By Joe Kucinski | 2026-04-29 16:11:56


VIEW MORE
story-6
9 Audi Designs That Aged Like Fine Wine

Slideshow: A look back at the Audis that didn't just survive changing tastes, they quietly outgrew them.

By Verdad Gallardo | 2026-04-28 19:38:27


VIEW MORE
story-7
2026 Audi Q5 Buyer's Guide (Every Model Explained)

One year off a full redesign, the best-selling Q5 is getting a few more updates.

By Brett Foote | 2026-04-17 09:56:19


VIEW MORE
story-8
Ranking Every Current Audi 'S' Model From Worst to First!

Slideshow: Ranking every current Audi 'S' model on sale today from worst to best.

By Joe Kucinski | 2026-04-16 10:28:28


VIEW MORE
story-9
10 Best Audis That are FINALLY LEGAL to Import to the U.S.!

Slideshow: 10 best Audis that are finally legal to import to the U.S.

By Joe Kucinski | 2026-03-24 17:20:08


VIEW MORE