473,769 Members | 2,106 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 2660

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

Similar topics

2
7512
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 in the nested query by specifying dates. These would somehow need to be passed to the nested query. I've looked into stored procedures/functions but am still stumped on
3
16947
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 create a parameter query in a stored procedure, but how do I use the result set of a parameter query in a select query (in the same or another sp)? In short, if a select query contains a result table that is generated as a parameter query, how do I...
12
3982
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 inherit attribute values from parent node. for example, say I have the following table: (nodeId int , color varchar, phone varchar) with two rows 5, "GREEN", "555-1212"
5
2350
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 found the logic is easier to implement (and later modify when the code is no longer freshly remembered), by implementing the processing layers in nested views, and functions that call sub-functions (UDFs), not too unlike object based programming...
4
4107
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 results, then doing a self left join with those results, etc. What puzzles me is that the time required for the query seems to grow exponentially as I add additional left joins, which I didn't expect. I expected the inner select to return about 25...
5
11114
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 The queries are nested, and they both use parameters. In MS Acccess the management of nested queries with parameters is so easy (implicit declaration of parameters, transmission of parameters from main query to nested query)
7
5675
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 invalid, but we are doing no such thing... After banging my head on the wall for a bit I noticed that the two stored procedures that are experiencing this behavior are procedures that are called from within another procedure (they're not both...
3
6472
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 COULD be wrong... :) I've tried the access group...twice...and all I get is "Access doesn't like ".", which I know, or that my query names are too long, as there's a limit to the length of the SQL statement(s). But this works when I don't try to...
3
9766
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 group by brch_nbr having sum_amount 0 order by sum_amount desc ;
1
9717
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
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7413
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3965
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 we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.