472,371 Members | 1,489 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 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 1077
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

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.