Query Design / Capability

Oct 2, 2007

Hello, I am trying to achieve a query results with not much luck. I am struggling the query design of how to construct to get the right results.

My table has the following data

RoomID  Subject         StartDate                Duration(min)           EndDate

  201       test       28/09/2007 07:00:00            180              28/09/2007 10:00:00

  202       test       28/09/2007 09:00:00            240              28/09/2007 13:00:00

 

The best way to describe is a scheduling system with the StartDate, Duration, EndDate.

I am trying to query for datetime periods which are allocated, eg the table records show from 7am - 10am and 9am - 1pm are allocated.

When I query on StartDate >=  28/09/2007 07:00:00   AND    EndDate <= 28/09/2007 13:00:00, record 201 & 202 shows which is correct because they are within query parameters and are allocated.

When I query on StartDate >=  28/09/2007 07:30:00   AND    EndDate <= 28/09/2007 13:00:00, record 202 only shows which is correct because record 201 StartDate is before 07:00:00.

But my problem is I require record 201 to show because the time period between 07:00:00 and 09:00:00 is allocated and the query parameter is 07:30:00 which is still between 07:00:00 and 09:00:00.

I have researched where on similar situations, the use of duration is used, but I am unsure on its application to achieve results.

I have also read of other situations where a lookup table should be used, but again I cannot get my head around the application of alookup table to query the resuults.

 

Does anyone have any theories, design thoughts or real work solutions they can help me with.

 

Thanks

Peter Smith

 

 

View 9 Replies


ADVERTISEMENT

Query Help / Capability

Oct 2, 2007

Hello, I am trying to achieve a query results with not much luck. I am struggling the query design of how to construct to get the right results.


My table has the following data


RoomID Subject StartDate Duration(min) EndDate
201 test 28/09/2007 07:00:00 180 28/09/2007 10:00:00

202 test 28/09/2007 09:00:00 240 28/09/2007 13:00:00



The best way to describe is a scheduling system with the StartDate, Duration, EndDate.


I am trying to query for datetime periods which are allocated, eg the table records show from 7am - 10am and 9am - 1pm are allocated.


When I query on StartDate >= 28/09/2007 07:00:00 AND EndDate <= 28/09/2007 13:00:00, record 201 & 202 shows which is correct because they are within query parameters and are allocated.


When I query on StartDate >= 28/09/2007 07:30:00 AND EndDate <= 28/09/2007 13:00:00, record 202 only shows which is correct because record 201 StartDate is before 07:00:00.


But my problem is I require record 201 to show because the time period between 07:00:00 and 09:00:00 is allocated and the query parameter is 07:30:00 which is still between 07:00:00 and 09:00:00.


I have researched where on similar situations, the use of duration is used, but I am unsure on its application to achieve results.

I have also read of other situations where a lookup table should be used, but again I cannot get my head around the application of a lookup table to query the resuults.



Does anyone have any theories, design thoughts or real work solutions they can help me with.



Thanks

Peter Smith

View 3 Replies View Related

Database Design/query Design

Feb 13, 2002

Ok, I'm doing a football database for fixtures and stuff. The problem I am having is that in a fixture, there is both a home, and an away team. The tables as a result are something like this:

-------
Fixture
-------
fix_id
fix_date
fix_played

----
Team
----
tem_id
tem_name

-----------
TeamFixture
-----------
fix_id
tem_id
homeorawayteam
goals

It's not exactly like that, but you get the point. The question is, can I do a fixture query which results in one record per fixture, showing both teams details. The first in a hometeam field and the second in an away team field.

Fixture contains the details about the fixture like date and fixture id and has it been played

Team contains team info like team id, name, associated graphic

TeamFixture is the table which links the fixture to it's home and away team.

TeamFixture exists to prevent a many to many type relationship.

Make sense? Sorry if this turns out to be really easy, just can't get my head around it at the mo!

View 2 Replies View Related

SSIS Capability?

Feb 20, 2006

Is there a restartability and ability to skip x number of rows (Restart Logic) in SSIS?

can ssis allow rollback for unsuccessful completion of load process  by record????

Pls give me example

View 1 Replies View Related

Better Charting Capability

Jun 15, 2007

Has anyone heard as to whether Microsoft plans on updating the charting engine for Reporting Services? Right now I find the charting capability rather limited and would like to see richer charting capability. Is this a case where it is better to not wait for this feature as it will be way off into the future before this happens, or better charting features just are not in the scope of Microsoft's plans for Reporting Services. If either case is true then the best solution would be to purchase the full capabilities of Dundas Chart for Reporting Services.

View 1 Replies View Related

Powerful Search Capability

Oct 30, 2006

How to build a powerful search capability in SQL Server 2005?TIA

View 2 Replies View Related

Sorting Capability On A Column

Jan 27, 2014

I need to sort on a column that has a mix of alpha/numeric...

oActual Sort: A1, A100, A14, A2, A222, A25 …
oFavored Sort: A1, A14, A100, A2, A25, A222 …

View 4 Replies View Related

Site Search Capability

Feb 27, 2008

I have a MS SQL database that is used with my Web site. I want to enable simple search capability where one or more words could be entered in a text box and have it search certain columns in my database for occurrences of those words. I've never done this before and so I'm not sure how to get started. Can someone help me begin? Thanks!

View 1 Replies View Related

Zoom Capability In Charts

Jan 11, 2008

I am working on creating charts in Windows Application, client-side report development, and the user requires to have a zoom capability on the chart area. For example zoom a piece of chart as selected by the user and then zoom out. Does anyone know that how can it be achieved?
Thanks a lot in advance.

View 3 Replies View Related

MSDE Capability/Error Message

Jan 6, 2004

We are thinking of deploying MSDE for a modest traffic Intranet. According to this http://www.microsoft.com/sql/msde/howtobuy/msdeuse.asp 25 concurrent users should be fine.

What exception would we get if the MSDE was not handling the traffic?

What would be the best way to track/log how close we are getting to the 25 user max.

Thanks

Simon

View 4 Replies View Related

Ideas In Designing Ad Hoc Capability Feature

Jul 23, 2004

I am looking for a solution to allow users to generate data by selecting tables-->columns-->where clauses on the fly.

I am thinking to maintain relationships, joins, etc., in some configuration tables. Based on the fields selected by the user, I can get these conditions and generate a query, execute and export to excel. Any ideas what is the good way of storing relationships, etc. in configuration table?

Also suggest if there is any good excel add-in to do adhoc reporting. Point me if there is any other ways of doing.

If I have to do it from scratch, i probably use VB.NET.

Any ideas, information is appreciated. thanks

View 5 Replies View Related

Capability For Limiting # Of Package Instances?

Oct 5, 2007

1) How can I keep my package from running more thatn 1 instance at a time?

I tried changing "MAXCONCURRENT" to "1" in my DTEXEC command in batch file, however, this doesn't limit the # of instances. (If I run the batch file twice, one after the next, I get 2 instances running simultaneously).



2) What "executable files" is this definition referring to?


MAXCONCURRENT is defined as:

"Specifies the number of executable files that the package can run concurrently. The value specified must be either a non-negative integer, or -1. A value of -1 means that SSIS will allow a maximum number of concurrently running executables that is equal to the total number of processors on the computer executing the package, plus two."


Thx,

Mojo

View 3 Replies View Related

The System Could Not Verify That The Destination Supports Secure Storage Capability

Oct 27, 2005

I am trying to save my package (using MS Visual Studio) with ProtectionLevel = ServerStorage but it is failing with the following error "failed to apply package protection with error 0xC0014061, the protection level, serverstorage, cannot be used when saving to this destination.  The system could not verify that the destination supports secure storage capability...".   I am trying to test a scenario on which the package is saved in SQL Server/msdb and schedule the package via SQL Job Agent.  Can someone show me how to save a package using serverstorage and schedule it via SQL Job Agent?

View 4 Replies View Related

How To Design This Query?

Aug 20, 2007

table a
id pct
1 0.1
2 0.24
3 0.5

table b
year amount
2001 10
2002 20
2003 30
2004 23
2005 67
2006 80

I want to create a table ret
wiht this
year newamount
2006 80*0.1+67*0.24+23*0.25
2005 67*0.1+27*0.24+30*0.25
2004 23*0.1+30*0.24+20*0.25
2003 30*0.1+20*0.24+10*0.25=9.9

How can i do that.
Thanks.
Jeff

View 5 Replies View Related

Query Design

Oct 27, 2007

hi

i am new to t-sql. the problem is i have to subtract a field from a column A in table X from a field in Column R from Table Y and put the subtracted value in the Column K in the Table Z

ex:

Table Name: Order
Field Name: Boxes

Table Name: Despatch
Field Name: Boxes

Table Name: Balance
Field Name: Boxes

the problem is i have to subtract the values(Boxes) in the table Despatch, from the values(Boxes) in the table Order, and the subtracted value has to be put in values(Boxes) in the table Balance.


can any one help?

one more thing: Where i can get the basics of t-sql



regards.,

sekar.r

View 2 Replies View Related

Database/Query Design Help

Oct 2, 2005

I am designing an ASP.NET app that can be used to keep track of
attendance at office hours for a class.  The purpose of this is
that we need to know if a student is attending office hours by
different people (so that we can flag them as "in trouble").  I
don't know if I have chosen the best database design, and I'm lost as
to how to accomplish a query I need.

I have a table HoursAttendance that has the following design.

Column_Name   Data_Type   Length   Allow_Nulls
TA              
      char        
      4         
n
Date              
    smalldatetime 4     
    n
Start              
    smallint         
2          n
End              
     smallint     
    2          n
Student1            
bit              
  1          y
Student2            
bit              
  1          y
Student3            
bit              
  1          y
Student4            
bit              
  1          y
Student5            
bit              
  1          y

I chose to have the students as columns because the students don't
change, and then you add rows of office hours.  If students are
the rows, then you would be adding columns as the semester continued
which I thought was odder...?  I'm completely open to suggestions
on Database Design, because I really wasn't sure.

Ok, so now I need useful queries.  The one that I am stuck on (and
also the first one besides select * from HoursAttendance) is that I
want the names of Students who have attended more than x office
hours.  So I need something like

    select <column name> from HoursAttendance where count(sum(<column name>)) > x

Granted a better table design could help with this.  I'm
relatively new to design, so constructive criticism is desired please

View 7 Replies View Related

Simple SQL Query Or Design Problem?

Nov 21, 2005

Dear All

I have posted this a few days ago, but probably didn’t describe it properly so I’ll attempt it again.

I’m wondering if it’s the design that needs to be changed or I simply can’t put this together.

I have 3 tables.

1. people (peopId, peopFName, peopSName etc.)
2. codes (codeId, codeName)
3. codedPeople(codePeopleId, peopId, codeId)

Codes represent different skills that people might have, like:

Technology-Founder
Technology-Chief Executive Officer
Technology-Systems Designer
etc.

people, clearly holds data about people.

CodedPeople holds data on which people in the db are coded what skills.

What I need is a query that returns all distinct people records and takes a number of codeNames as input.

So if I have person1 and person2 in the db and they are coded as:

Person1 is a t-Founder
Person1 is a t-CEO

Person2 is a t-Systems Designer

Query 1, looking for all t-CEO
Result 1: person1

Query 2, looking for all t-CEO AND t-Founder
Result 2: person1

Query 3, looking for all t-CEO OR t-Systems Designer
Result 3: person1, person2

Query 4, looking for all t-Founder AND t-Systems Designer
Result 4: -


I have:

[ code]
SELECT people.peopId, peopFName, peopSName, peopPhoneHome, peopPhoneMobile, peopEmail, codes.codeId, codename
FROM people INNER JOIN codedPeople ON people.peopId = codedPeople.peopId
INNER JOIN codes ON codes.codeId = codedPeople.codeId
WHERE ( parameter )
ORDER BY peopSName, peopFName
[ /code]

And I add in parameters from my front end to the WHERE clause, like in the example:

Parameter = ( codeName LIKE 't-CEO' ) OR ( codeName LIKE 't-CFO' )


This works fine when using OR but doesn’t work when trying to use AND in a sense of a person is coded with skill1 AND skill2 AND skill3 etc.

Any idea how to implement what I need to achieve?

View 14 Replies View Related

Can Not See Columns In Query Design View

Nov 3, 2006

Even though I select "Column Names" in Design View when creating a query (or view), only "* (All Columns)" appears in the table box.

In InfoPath, when I connect a combo-box, err drop down box, to the database, I am unable to connect directly to a table... no tables are shown. If I select a different database, these problems do not exist.

I can not find any setting to allow these columns to be shown in the design view or any setting that will "expose" the tables in InfoPath.

I tried creating a new database and exporting the data, tables and data, from the troubled DB to the new DB; however, the new DB exhibited the same behaviour. The system tables, Master and Model, have the same behaviour. Please help me with your ideas and suggestions... thank you very much for your time.

This database was upsized from Access 2003 to SQL Server 2000 SP4.

rogge

View 7 Replies View Related

Switch Of Query Design Mode

Feb 13, 2007

Hi all,

I have a couple of reports with predefined queries. When I try to edit a data set query it goes directly to query design mode losing the query I already had. As you can see this is a real problem because I can't edit queries. How can I switch off design mode? any ideas are pretty much appreciated.

Cheers

View 3 Replies View Related

How Would You Design This Query Better ( Does Not Contain Lots Of Code)

Apr 18, 2006

i have a number of business programs. Each program is started anew at the beginning of each fiscal year. each program has a number of goals and customers subscribe to the goals.

i have to pull all this info out of the database.

i have a cursor that gets the first program, inside this program i have a cursor that gets the first period, and inside that i have a cursor that gets the info on each goal.

program cursor

{

period cursor

{

goal cursor

}

}

}

}

this takes ages ( hours and hours ) to run. is there any way i could have designed this using joins and simple selects to make it more efficient??

View 4 Replies View Related

SQL Query Analyzer -&> Design View -&>Save

May 14, 2007

in SQL Query analyzer i get the desired result for the following querry succesfull.

But can any one help me in getting the same result in design view so that i can save this view and get the required result on my aspx page.(Web page)

A beginer !!!! not much familiar with MS SQl.....HELP>>>

USE nfxdash SELECT *, DATEDIFF(day, Date_Opened, getdate()) AS no_of_days
FROM nf_Tickets

View 1 Replies View Related

Blonde To Write Query Or Design Fault

Nov 18, 2005

Dear All,

I’m wondering if it’s the design that needs to be changed or I simply can’t put this together.

I have 3 tables.

1. people (peopId, peopFName, peopSName etc.)
2. codes (codeId, codeName)
3. codedPeople(codePeopleId, peopId, codeId)

Codes represent different skills of people, example the sort of job functions they’ve held in their employment. Like:

t-CEO,
t-CFO
t-Founder
etc.

people, clearly holds data about people.

CodedPeople holds data about which people are coded. So person1 can be coded as t-CEO as well t-Founder, and person2 coded as t-CFO

What I need is a query that returns all distinct people records and takes a number of codeNames as input. So if I throw in t-CEO OR t-Founder I get person1, again if I define t-CEO AND t-Founder I get person1.

However when I add t-CEO OR t-CFO I get person1 and person2 but when the query takes t-CEO AND t-CFO I get no result.

I can’t seem to come up with anything that would give me a good starting point. Is there a design fault here? All opinions are much appreciated, thanks in advance!

View 3 Replies View Related

Data Model Design For Query Performance

Apr 22, 2008

I have an opportunity to rebuild a database model with the express purpose of improving query performance. So given the following I have a few questions.

Table A (~500M records)
Primary Key Field (int)
Field 1 (varchar)
Field 2 (varchar)
Field 3 (varchar)
Field 4 (varchar)
Field 5 (varchar)

Table B (1B+ records)
Primary Key Field (int)
Foreign Key Field (int)
Field 1 (varchar)
Field 2 (varchar)
Field 3 (varchar)
Field 4 (varchar)
Field 5 (varchar)

* Assumed: Tables are inner joined on all queries. The database is readonly.

-- Most of my lookups are based on querying Field 1 of Table A. The data content of Field 1, Table A is 90% unique.
1) Would it be more beneficial to put the clustered index on Field 1 instead of the PK field in Table A?
2) Can an Identity column be non-clustered?
3) Alternatively, would it be beneficial to build a separate lookup table with just the PK & Field 1 of Table A, with a clustered index on the lookup table Field 1 which I join on Table A? (did that make sense?)

-- I have a secondary lookup that performs queries on Fields 1, 2, 3, 4 & 5 of Table B
1) Would it be more beneficial to create an additional indexed lookup column of the concantenated values of Fields 1-5 of Table B versus a covering index of all 5 columns?
2) Does a clustered index have to be unique?
3) Would a clustered index be more beneficial over Fields 1-5 or the special lookup column versus the PK or FK fields?
4) Would creating a special lookup table with just the requisite fields be more beneficial?

An extra question. The existing data model uses the CHAR datatype for all columns less than 9 characters wide and the columns are set to allow nulls. This requires every select statement to COALESCE() and RTRIM() all these columns. I intend to make all (affected) columns VARCHAR, NOT NULL with a default value of a 0-length string.
Will this enhance query performance?

Thanks in advance for any insight.

View 7 Replies View Related

Query Design For Adding / Copying And Updating

Jul 8, 2013

I have a rather complex query (to me at least) that I need to create but I am unsure of where to start. The query requires me to copy existing data into a new row (which will then create a new ID) as well as update all existing records with the newly created id. More specifically, I need to separate the data associated with LocationID 219 from it's parent, CompanyID 992.

Ideally I want to copy the data associated with LocationId 219 and then make a new CompanyId with the copied data (which will also create a new LocationID). Since this new record is no longer going to be associated with CompanyID 992 I will want to remove/delete/drop it from that record.

Finally, and perhaps most difficult of all, I need to update all tables that reference the old ID's together (992 / 219) to reflect the newly created Company ID and Location ID.

View 3 Replies View Related

SQL Query (SELECT Statement) And Table Design

Aug 19, 2007

I am wondering if there is a direct query in this case:


I am developing a program to a company which simply sells services
One service may have different prices for different types of clients
The price of any service for any client can change at any time, and I should be able to trace these changes at any time

I made the following tables (simplified): (asterisk for primary key)

(Table) (Fields)

CLIENT_TYPES : ID*, ClientTypeName
SERVICES : ID*, ServiceName
PRICES : ServiceID*, ClientTypeID*, Price, Date*
ORDERS : ID*, Date, ClientTypeID
ORDER_SERVICES : OrderID*, ServiceID*

The field in bold is the area of the question

This is a sample data in the PRICES table:

ServiceID ClientTypeID Price Date1 1 100 1/1/20072 1 150 1/1/20071 2 90 1/1/20072 2 135 1/1/2007

Now if I want to update a price of service 1 for clienttype 1, I add the following row:

1 1 100 1/1/2008

So one product for one client can have any number of prices with different dates


The following query:

SELECT * FROM PRICES WHERE ClientTypeID = 1

will retrieve all prices with repeats for a specific client (#1 here)

What I want is a query to retrieve the most recent prices for specific client for all products, even if a query on query

If there is commemts on table design please tell me

thanks for any one who provides help

View 6 Replies View Related

Error In Building SQL Query Within LIKE Statement For TableAdapter In Design Section

May 31, 2006

ASP.net 2.0 (VB), SQL Server 2005:While creating a new TableAdapter in design section, I'm using the query builder and trying to write a query within "LIKE" statement as below -Example1: SELECT * FROM table WHERE field LIKE @'%TextBoxData%'Example2: SELECT * FROM table WHERE field LIKE '%@TextBoxData%'
but these query doesn't work...error in building query...any clue to make it work? If I remove "@" sure the query will work with normal but '%TextBoxData%' will become a hardcoding value...this is not I want...I want make the TextBoxData become a flexible value depend on the data what I enter in my text box like 'abc,123' not like 'TextBoxData'...
I know normally it supposed to be like:
 "SELECT * FROM table WHERE field LIKE '%" & TextBoxData.Text & "%'"
It can work when in Code Section, but not at this time...because now i'm trying to made it with "Query Builder" for TableAdapter " in Design Section...hmm did you get what I mean? Sorry for my bad english
Thanks in advance

View 3 Replies View Related

DB Design :: Optimize A Query That Uses A Varchar Column That Is Used In Order By Clause

May 5, 2015

I am querying a tableA with 1.8 million rows, it has id as its primary key and is a clustered index. I need to select all rows where I order by lastname. Its taking me 45 seconds. Is there anything i can do to optimize the query.Will creating a fulltext index on lastname If so, can you give me an example on how to create a full text index on lastname?

[Project1].[Id] AS [Id], 
[Project1].[DirectoryId] AS [DirectoryId], 
[Project1].[SPI] AS [SPI], 
[Project1].[FirstName] AS [FirstName], 
[Project1].[LastName] AS [LastName], 
[Project1].[NPI] AS [NPI], 
[Project1].[AddressLine1] AS [AddressLine1], 
[Project1].[AddressLine2] AS [AddressLine2], 

[code]...

View 5 Replies View Related

In Query Builder Design View, How Does The Filter Operator MDX Work?

Nov 12, 2007

Good morning all,

I have searched everywhere for this and I can't find any information on it. When I use the Query Builder, in the top pane, the Filter pane, there are five columnsimension, Hierarchy, Operator, Filter Expession and Parameters.

In the dropdown for Operator, one of the choices is MDX. I cannot find any documentation on how to use this operator. I want to limit my filter to SELF_AND_AFTER, and I am hoping that this is possible using this operator. I know how to hand code it, but I have a ton of other tweaks to make to the query, so I want to use the Query Designer as much as I can.

Does anyone have any links to documentation on how to use this operator?

Thanks,
Kathryn

View 2 Replies View Related

Reporting Services :: Query Timeout In Report Builder Design Mode

May 18, 2012

I have a very frustrating problem.  But given that this is a development forum, I'll keep that for my 'Envelope Lickers Rehab' and instead talk about an issue I'm having.

I have a very large query (line-wise) that executes in less than a minute when run from the SQL Management Studio as well as via Excel Services. 

It is a stored procedure with one parameter. When I try to prime the designer with this query it gives me the following message:

"Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
The statement has been terminated."

I've considered cracking open the xml source and manually creating the fields, but I'd rather not go there.

View 8 Replies View Related

Reporting Services :: SSRS Dataset Query Design Error Source

Nov 3, 2015

When  I click on the DataSet Query Desginer there is an Error Source:.NetSqlClient Data Provider. why this error comes and I have executed the SQL query in SSMS succesfully and the result comes. However this is causing the report from the report manager to fail.

View 8 Replies View Related

DB Design :: How To Return Only 25 Rows At A Time From Query To Web Page That Interact With Server

Sep 16, 2015

How to design at database level such a way so that when I implement a SQL query that returns one hundred thousand rows only display 25 rows at the client (Web page at a time). How can I accomplish this?

Once I display first 25 rows then how do I bring next 25 rows and so on. Can it be done via paging or there are other techniques. However I asked to design this in the database level. I am using MS SQL Server 2008. Front end Visual Studio 2010. I use C# for coding. 

View 14 Replies View Related

SQL Server 2012 :: Query Design - Find Most Recent Datetime Record Each Day For A Customer

Apr 2, 2015

So I have a query that need to find the most recent datetime record each day for a customer. So I have a query that looks like this:

SELECT
dhi.[GUID],
dhi.[timestamp],
la.[bundle_id],
dhi.[value]
FROM
[dbo].[DecisionHistoryItem] as dhi WITH(NOLOCK)

[Code] ....

View 4 Replies View Related

DB Design :: Database Design For Matrix Representation

May 13, 2015

I have a scenario like below

Product1
Product2 Product3
Product4 Product5
Product1 1
1 0 0
1
Product2 1
1 0 0
1
Product3 0
0 1 1
0
Product4 0
0 1 1
0
Product5 1
1 0 0
1

How to design tables in SQL Server for the above.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved