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

Query Formating In Sql-need help

Hi can one help me in sorting out the query
This is the table I have with me.
Can one help me in sorting out the query.


start_date end_date bus_hol
2007-04-14 2007-05-01 ?
2007-04-03 2007-05-01 2007-11-01
2007-04-18 2007-05-01 2007-11-09
2007-04-01 2007-05-01 2007-09-19
2007-04-02 2007-05-01 2007-09-02
2007-03-29 2007-05-01 2007-08-15
2007-04-04 2007-05-01 2007-11-08
2007-04-07 2007-05-01 2007-12-21
2007-04-17 2007-05-01 ?
2007-04-09 2007-05-01 ?
2007-03-31 2007-05-01 2007-01-26
2007-04-15 2007-05-01 ?
2007-04-10 2007-05-01 ?
2007-04-13 2007-05-01 2007-12-24
2007-04-05 2007-05-01 ?
2007-03-28 2007-05-01 2007-04-06
2007-04-11 2007-05-01 ?
2007-04-12 2007-05-01 ?
2007-03-30 2007-05-01 2007-01-01
2007-04-08 2007-05-01 2007-12-25
2007-04-06 2007-05-01 ?
2007-04-16 2007-05-01 2007-12-31



The output should be as follows.
The bus_hol should be between start_date and end_date

Start_date end_date count(bus_hol)
2007-04-14 2007-05-01 0
.
.
.

.
.

.
2007-04-05 2007-05-01 1 (bec 2007-04-06 is betwwen start_ date and end_date)

Thanks in Advance

krishna
May 2 '07 #1
3 1134
MMcCarthy
14,534 Expert Mod 8TB
Try this, not sure if it will work
Expand|Select|Wrap|Line Numbers
  1. SELECT  start_date, end_date, 
  2. Sum(IF bus_hol BETWEEN  start_date AND end_date 1 ELSE 0) As CountBusHol
  3. FROM tablename
  4. GROUP BY start_date, end_date
  5.  
May 2 '07 #2
Try this, not sure if it will work
Expand|Select|Wrap|Line Numbers
  1. SELECT  start_date, end_date, 
  2. Sum(IF bus_hol BETWEEN  start_date AND end_date 1 ELSE 0) As CountBusHol
  3. FROM tablename
  4. GROUP BY start_date, end_date
  5.  
Hi Thank you.
i tried its giving some different results than my expectations.
May 3 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
Hi Thank you.
i tried its giving some different results than my expectations.
Look at each date range and see if you can follow what results are being produced and how this differs from expeced results.
May 3 '07 #4

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

Similar topics

2
by: jaysonsch | last post by:
Hello! I am having some problems with a database query that I am trying to do. I am trying to develop a way to search a database for an entry and then edit the existing values. Upon submit, the...
0
by: rodrigo guerra | last post by:
where i can change the code formating that visual studio does in the code.... like if i type: if ( ) { .... } visual studio changes to:
1
by: Norton | last post by:
Hi all , i would like to make a small utility which allow me to reformat the sql statement from clipboard. I am finding ways which allow me to make use of MS SQL's Query Designer. ...
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
4
by: ScarletPimpernal | last post by:
Hi Friends, I have a table with field Id--vDate ------------- 1--3/1/2007 12:00:00 AM 2--4/1/2007 12:00:00 AM 3--4/12/2007 5:28:15 PM 4--3/1/2005 12:00:00 AM
3
uranuskid
by: uranuskid | last post by:
Hey folks, I have aliile issue with my Date. I query the data base with a comperative query (see below) and want to get the date in a different format. At first the query: $query =...
7
by: sukeshchand | last post by:
any body have an idea abou how to wirte a function for formating a numeric field. Ex: In my table the TotalAmout is a numeric field. if i use (Select TotalAmount from Table1) then query will return...
4
by: Newbie12345 | last post by:
I have a crosstab query which gathers data from a regular table and creates columns for the months in the year with volume for each month. I want to be able export/send the data to a brand new table,...
3
by: Soulspike | last post by:
Hello all I have a little formating problem. I have a query with the following code for one of the fields IIf(DatePart("ww",!,2,2)=53,"1", (DatePart("ww",!,2,2))) This code should...
5
by: StarryNight | last post by:
I hate doing this but I've tried for hours to solve this problem. I'm trying to format a listbox to show the number as currency. The list box is controled by a query. here is the code: SELECT...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
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,...

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.