473,508 Members | 2,363 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Nested SELECT FROM WHERE AS IN

enfuego
3 New Member
The code below give an error of
Expand|Select|Wrap|Line Numbers
  1. Msg 170, Level 15, State 1, Line 5
  2. Line 5: Incorrect syntax near '='.
  3. Msg 170, Level 15, State 1, Line 8
  4. Line 8: Incorrect syntax near '='.
I Am not sure why. Plz advize. Thank you in advance.
Expand|Select|Wrap|Line Numbers
  1. SELECT     xxx.reviews.id, xxx.reviews.techCompany, xxx.reviews.jobSummary, xxx.reviews.inspectionDate, xxx.callTypeReview.reviewId, xxx.callTypeReview.callType, 
  2. xxx.findingsComments.reviewId, xxx.findingsComments.meetsSpec,xxx.findingsComments.findingType,
  3. (SELECT COUNT(DISTINCT xxx.reviews.id) AS DP FROM xxx.reviews AS Expr1 WHERE 
  4. EXISTS(SELECT COUNT(reviewId) AS ReviewCnt1 
  5. FROM xxx.callTypeReview AS Expr2 WHERE Expr2.callType = 'Digital Phone' AND Expr2.callType IN ("HSD Install/Upgrade", "Commercial HSD", "Commercial Video", "Install: Video", "restart/reconnect: Video")) AND Expr1.jobSummary = 'Pass')= 2),
  6. (SELECT COUNT(DISTINCT xxx.reviews.id) AS DP FROM xxx.reviews AS Expr2 WHERE 
  7. EXISTS(SELECT COUNT(reviewId) AS ReviewCnt2 
  8. FROM xxx.callTypeReview AS Expr3 WHERE Expr3.callType = 'Digital Phone' AND Expr3.callType IN ("HSD Install/Upgrade", "Commercial HSD", "Commercial Video", "Install: Video", "restart/reconnect: Video")) AND Expr2.jobSummary = 'Pass')= 3)        
  9. FROM         xxx.callTypeReview INNER JOIN
  10.                       xxx.findingsComments ON xxx.callTypeReview.reviewId = xxx.findingsComments.reviewId INNER JOIN
  11.                       xxx.reviews ON xxx.findingsComments.reviewId = xxx.reviews.id
  12. WHERE     (DATEDIFF(d, xxx.reviews.inspectionDate, GETDATE()) BETWEEN 0 AND 5) AND (DATEDIFF(m, xxx.reviews.inspectionDate, GETDATE()) = 0) AND 
  13.                       (DATEDIFF(y, xxx.reviews.inspectionDate, GETDATE()) = 0) AND (DATEPART(dw, xxx.reviews.inspectionDate) BETWEEN 2 AND 6) AND 
  14.                       (xxx.reviews.techCompany LIKE '"%"@region')
  15. GROUP BY xxx.reviews.techCompany, dbo.reviews.id
  16. ORDER BY xxx.reviews.inspectionDate DESC
Jan 4 '08 #1
0 2645

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

Similar topics

2
7489
by: Forgone Conclusion | last post by:
Hi, I have a View that groups and sums up totals. This View is then nested within in another View and used (it needs to be done like this). What i need to do is to be able to vary the records...
3
16928
by: WGW | last post by:
Though I am a novice to MS SQL server (2000 I believe), I can do almost! everything I need. Maybe not efficiently, but usefully. However, I have a problem -- a complex query problem... I can...
12
3955
by: Jeff Lanfield | last post by:
First of all, I apologize if coalescing is not the right term to describe my problem. I have a tree where each node has the same set of attributes (is the same entity) but child nodes should...
5
2328
by: Matt | last post by:
I am working in a project where the business model is complex enough that many common retrieval functions become difficult to develop and maintain in single query statements or functions. I have...
4
4090
by: jbm05 | last post by:
Hi, I'm curious about the computational complexity of a query I have. The query contains multiple nested self left joins, starting with a simple select, then doing a self left join with the...
5
11102
by: ahokdac-sql | last post by:
Hi, I'm adapting access queries to sql server and I have difficulties with the following pattern : query1 : SELECT * FROM Query2 WHERE A=@param1 query 2: SELECT * FROM Table2 WHERE B=@param2 ...
7
5655
by: Anthony Robinson | last post by:
Have been encountering an odd issue. Every now and again, certain packages of stored procedures just become invalid. I'm aware that dropping or altering an underlying table would render a package...
3
6425
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
3
9748
by: Frank Swarbrick | last post by:
I was just messing around trying to learn things and attempted the following: select brch_nbr , sum(case when post_flag != 'P' then amount else 0 end) as sum_amount from film.film_transactions...
1
9683
by: nanoman | last post by:
Hello, I've got a Nested Set structure in MySQL 4 here with - id - lft - rgt - parent_id - root_id I wrote some test scripts and i discovered that the Nested Set (the
0
7223
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
7115
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
7377
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...
0
5624
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
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
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
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1547
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
414
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.