473,383 Members | 1,859 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,383 software developers and data experts.

What is the syntax for nesting a query in mssql2005

In the following query I want to pull the same data (Qty, Line Total & Gross Profit)for a different date range and append it to the right of the data range so I have the data for 2 periods of time. What is the syntax for nesting this?

Expand|Select|Wrap|Line Numbers
  1. SELECT c.SlpName, a.CardCode, a.CardName, INV1.ItemCode, b.ItemName, Sum(INV1.Quantity), Sum(INV1.LineTotal), Sum(INV1.GrssProfit)
  2.  
  3. FROM CALLHAVEN.dbo.INV1
  4.  
  5. Left outer join CALLHAVEN.dbo.OINV a on INV1.DocEntry = a.DocEntry 
  6. Left outer join CALLHAVEN.dbo.OITM b on INV1.ItemCode = b.ItemCode
  7. Left outer join CALLHAVEN.dbo.OSLP c on INV1.SlpCode = c.SlpCode
  8.  
  9. WHERE (INV1.DocDate Between {ts '2010-03-01 00:00:00'} And {ts '2010-08-31 00:00:00'}) and SlpName = 'Bob Middleton'
  10.  
  11. GROUP BY c.SlpName, a.CardCode, a.CardName, INV1.ItemCode, b.ItemName 
Mar 17 '11 #1
0 985

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

Similar topics

2
by: John | last post by:
Hi I am using the this time syntax in an acess query; iif(>=#12:00:00 PM#,"PM","AM"). Problem is that I am getting error on the date expression. What is the correct expression to represent 12...
3
by: Keith | last post by:
I've inherited an Access file in which there is the following query: SELECT tblItem.InstanceNo, "PL" & Left(.,InStr(.,"-")-1) AS Parent FROM tblItem, tblItem AS tblItem_1 WHERE ((("PL" &...
0
by: 1harsh789 | last post by:
Hi, Can anyone please tell me about What is ODBC Query timeout error? And How to resolve this issue. Thanks.
2
by: firdous | last post by:
Please help me to write the query for removing the auto_increment propery of the column or drop that column. Thank you!
4
by: arthuryeung198 | last post by:
Hello all, I have got an XML looks like the following. How can I use an XPATH command to select //hostname and //instance? If there is no instance in the sever, just skip, so it returns ...
1
by: skbhagour | last post by:
hi all i am using given below procedure what i want (i am using sql server2000 with vb.net in window advanceserver2000) 1.i want records between two given date for particular account...
5
by: sierra7 | last post by:
Hi Using Access 2002 on XP I want to run the subroutine of the After Update event of a control in a sub form after 'inserting' a value from elsewhere. My main form is and the subform is ,...
24
by: MU | last post by:
Hello I have some code that sets a dropdownlist control with a parameter from the querystring. However, when the querystring is empty, I get an error. Here is my code: Protected Sub...
3
by: mzahid | last post by:
I have 3 tables student(s_id,s_name),course(c_id,c_name) and student_course(s_id(FK),c_id(FK)). I would Like to select those students Name who have enrolled more then and equal to 3 courses. What...
1
by: dbytes | last post by:
I have no idea what sql command will return the results I need from 1 table. example of table and values col1 col2 col3(unique values) 1 1 abc 1 1 dev 1 2 rst 1 3 ndb 1 3 mnv
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.