473,399 Members | 3,106 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,399 software developers and data experts.

Trouble with getting this query

5
I'm still new to SQL and am trying to pull up a query that lists the order number, customer ID, and the number of days between order and shipment sorted by longest delivery time to the shortest, for all orders in 1996 only.

I think I have to use DATEDIFF on this but have never used it before - any help would be greatly appreciated.
Feb 1 '07 #1
3 1042
iburyak
1,017 Expert 512MB
Try this:

[PHP]SELECT [order number],[customer ID], DATEDIFF(d, order, shipment) Delivery
WHERE order BETWEEN '1996-01-01 00:00' AND '1996-12-31 23:59'
ORDER BY 3 DESC[/PHP]
Feb 1 '07 #2
Try this:

[PHP]SELECT [order number],[customer ID], DATEDIFF(d, order, shipment) Delivery from [ table name ]
WHERE order BETWEEN '1996-01-01 00:00' AND '1996-12-31 23:59'
ORDER BY 3 DESC[/PHP]

Use Table name
Feb 1 '07 #3
iburyak
1,017 Expert 512MB
I don't know what is your data structure. You have to check if names are correct and edit this query accordingly.

[PHP]SELECT [order number],[customer ID], DATEDIFF(d, order, shipment) Delivery
FROM table_name
WHERE order BETWEEN '1996-01-01 00:00' AND '1996-12-31 23:59'
ORDER BY 3 DESC [/PHP]
Feb 1 '07 #4

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

Similar topics

0
by: lowellturner | last post by:
We recently had to reload an app to a Linux server from its Window counterpart. I've tried setting the lower case global in my.cnf to al three values, but none work. Previously, this worked fine....
59
by: Rico | last post by:
Hello, I have an application that I'm converting to Access 2003 and SQL Server 2005 Express. The application uses extensive use of DAO and the SEEK method on indexes. I'm having an issue when...
3
by: fstenoughsnoopy | last post by:
Ok the complete story. I have a Contact Table, Query and Form, that are used to input and store the contact info for customers. They have FirstName, LastName and Address as the primary key...
0
by: harry12 | last post by:
Hello- I'm fairly new at using Microsoft Access and I'm having trouble getting a couple of things to work in my database. The first is that I have yet to find a way to get an append query to...
1
by: ferraro.joseph | last post by:
Hi, I'm querying Salesforce.com via their AJAX toolkit and outputting query results into a table. Currently, their toolkit does not possess the ability to do table joins via their structured...
5
by: tschulken | last post by:
I have a query where i need to look for a value of a lower level xml element based on the value of a parent element existing first. Here is a simple example of the xml <S3Client> <Buttons>...
1
by: nico3334 | last post by:
I'm having trouble with a query using "MAX". In my query I'm trying to use 2 date columns as my criteria. Here is the format for each column: Date1: 01/01/2007 Date2: 200701 For my...
6
by: MLH | last post by:
I have a query with a single table. One of the table fields appearing in the QBE grid is containing values from 1 to 127. Then I have the following calculated field named : Published: IIf((1...
1
by: George | last post by:
I have just loaded Access 2007 and am having trouble creating a new database where I update my table from a query. I have done this numerous times in years past but am totally frustrated tryng to...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
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
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
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
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
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
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...
0
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
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...

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.