Applied Math Problem - Creating A Cut List

Jan 28, 2008

I realize this gets into business logic, but a DB based solution might be best. Possibly some pre-calculated measurement tables.

Business problem: Creating a cut list for a window covering (blinds) system. It's preferably a fast calculation I could execute while the user awaits "order confirmation and pricing". A .5 second delay per order would be acceptable.

An order can have unlimited number of line items, but typically between 1 and 20 (number of windows in a single house).

(For this problem) the raw material is man-made, and therefore is always the same length for a particular pattern/color (take 12' for this example; we stock patterns in 9', 12', or 16' but it's always the same for a given pattern/color). I need to tell the cutters how to use the rawmaterial with minimal waste. Note: The saw blade takes 1/16th inch.

For each line item; I have pre-calculated the exact cut size and number of slats. Measurements are in inches at 1/8 (.125) inch increments. The length of raw material length we stock for this pattern is an easy link.

The goal is to average less than 6 inches waste per 12' piece of raw material.

Example order:

5 line items for pattern/color FAUX/white, stocked in 12' lengths.

Line 1: 34 slats at 35.125 inches.
Line 2: 36 slats at 36.875 inches.
Line 3: 50 slats at 42 inches.
Line 4: 55 slats at 70 inches.
Line 5: 52 slats at 30 inches.

The resulting cut-list-workorder would evaluate all lines together and tell them how many 12' slats to pull and how to cut them with minimal material waste.


My question:

I'm left wondering if a database style pre-populated answer list (or some other database based solution) might be a lot faster and simpler than some chess-style complex trial-and-error array based VB algorythm (that I haven't even begun to imagine how to write). If so; how would it look?

In addition; the cutters get something like $10/hr so we can't make it too complex. I'd rather waste a little material and avoid undue confusion, but not much. With $5+ million in this material per year, excess waste can really add up. Imagine the difference between 12% and 15% waste. It's an area worth investing in.

Sorry; I know it's not a simple question. Someone might find it interesting enough to solve, or at least provide hope for a DB solution. At present; I just can't imagine it.

View 3 Replies


ADVERTISEMENT

Need Help Creating Sub Agg List

Mar 6, 2008

I need help displaying information in a list on my report...

My dataset table extracts the fields, username and created date and my list is grouped by creator which puts each users info on its own page. My problem is that I cant figure out how to extract the following values:


The average number of items created per day/month/quarter/etc... (Most Important)

A sublist which displays the user's created count as follows: (Would be very greatful)



Code Snippet
Sample:

Created | Count | Percent
0-25 | 10 | 10%
26-75 | 50 | 50%
75+ | 40 | 40%

(I have figured out how to create these lists in the past using the grouping function on values, but becuase they would be counts instead of values I dont know how.)


Any tips or information would be helpful.

Thanks In Advance
Geoff

View 1 Replies View Related

Creating A Master List

Apr 16, 2008

How can I create a master list of a particular column, in other words is there a SELECT query I can do that would bring back one of every type of? here's an example: calls table -- bring back one of every kind of call_descr thx for any help.

View 1 Replies View Related

Creating A Comma Delimited List

Jul 11, 2005

Hi,

I have a complex query where each row in the final dataset is a
product.
However each product has a number of authors associated with it. 
What I
would like to do is have a query/subroutine join the authors to the
product,
as a string:


ProductID  
Title                       
Authors
1           The Sacred and the Profane   John Rieggle, George
Alexi
2           Dancing
in the Dark          Dan
Brown, Peter Kay, Paul
Dwebinski

Products
Table
==============
ProductID
Title

Authors
Table
=============
AuthorID
Name

Product Authors
Table
=====================
AuthorID
ProductID

Is this at all
possible?

Thanks

jr.

View 3 Replies View Related

Creating A Delimited List Of Data In SP W/O Cursor

Mar 29, 2001

SQL7 SP3

Hi.

I have a table in which I want to create a delimited list of values from one field which I will be using for validation.

How can I do this without using a cursor to build the string. The SQL would be something like:

SELECT *
FROM myCrossRefTable
WHERE SourceTable = 'FieldValueList'

I'm looking to return on string like -

~value1~value2~value3~value4~value5

Thanks,

Craig

View 2 Replies View Related

Creating A Form With A Drop Down List Of The Foreign Key Values

Jun 19, 2002

I have the following tables in an SQL Server database.

Contact
=======
NameID
TitleID
Name

JobTitle
========
TitleID
Title

I'm trying to make a form to add entries to the Contact table that lets me associate a job title to a name by choosing it from a drop down list. I have been able to make it so I get a drop down list of TitleID but I need the Title field displayed. I haven't been able to do it. Does anyone have any tips on how to do this?

View 1 Replies View Related

T-SQL (SS2K8) :: Creating Comma Separated List Of Details From Multiple Columns?

Jun 3, 2010

I am trying to find a way to add into a table a flattened (comma seperated list) of email addresses based on the multiple columns of nformation in another table (joined by customer_full_name and postcode.

This is to highlight duplicate email addresses for people under the same customer_full_name and Postcode.

I have done this using a loop which loops through concatenating the email addresses but it takes 1minute to do 1000. The table is 19,000 so this isn't really acceptable. I have tried temp tables, table variables and none of this seems to make any difference. I think that it is becuase i am joining on text columns?

Create table #tempa
(
customer_Full_Name varchar(100),
Customer_Email varchar(100),
Postcode varchar(100),
AlternateEmail varchar(max)NULL
)
insert into #tempa (customer_full_name,customer_email,postcode)

[code]....

View 9 Replies View Related

Math Or Text

Dec 13, 2006

in the below sql why is    year(classdate)  " + " a " + " MONTH(classdate)  a math command giving me   2006 - 12 = 167
and not "2006/12" as text? please help me
 cmdGetCat = New SqlDataAdapter("SELECT DISTINCT   year(classdate)  " + " a " + " MONTH(classdate) AS  monthcode  FROM  dbo.classT INNER JOIN dbo.classgiven ON dbo.classT.classcode = dbo.classgiven.classcode WHERE (dbo.classT.discount = '-1') AND  (dbo.classT.coned IS NOT NULL) ", conNorthwind)
 
 

View 4 Replies View Related

Sql Math Question

Nov 18, 2007

How do i update a sql table so that the result cannot be less than zero?for example, lets say I have the column "Number"I have a sql update statement that subtracts 1 from number:"Update oTable SET Number = (Number - 1)"Except that Number cannot be less than zero.  Is there a way to do this in sql statement so that I don't have to have a select statement just to check that Number is greater than zero to begin with? Thanks 

View 4 Replies View Related

Doing Math On Tables

Oct 26, 2004

Hello everyone:

I have a database for one of my websites, a picture rating site. Anyways, right now there are quicte a few tables, and I was wondering how to give the server a break and was wondering if this was possible:

Basicly I have a members table, and a votes table. Members will rate other users pcitures on a scale of one to ten, then the votes will be inserted into the votes table. The only problem with this is that calcuating all the votes a user has can put a straing on the server. I was wondering if it would be possible to create a math column in the members table that would automaticly figure out the users average and having it stored in a field in the members table, so all I would have to do is query the members average located in the mebers table, rather than tallying all the votes in the votes table for each member.

Hope this makes sense, a tutorial or any suggestions would be great!

Thanks

View 1 Replies View Related

Some Math Logics

Feb 2, 2004

I have 2 questions.

1) Lets say we have a table

CREATE TABLE TEST
(
N INT
)

These table have 10 records - the numbers from 1 to 10.

I need 1 query ONLY which will update the table and make it with 100 records - the numbers from 1 to 100.

2) How with 1 query ONLY i have select only the prime numbers

View 4 Replies View Related

Date Math In SQL - How To Do?

Jan 16, 2006

I have some dates stored in a field named "visit"

In a select they show as the format:
2005-07-28 10:45:00.000


So I need to write a query that will select Visits that are more than 90 days old. I thought it might be something simple like:

Select * from patientVisit where ((getdate())-Visit>90)

But that is pulling all visits not just 90 day old ones.

How do I pull the current date/time and compute the cutoff date time that would be 90 days prior for my selection Where clause?

Thanks

View 3 Replies View Related

Math Between Columns

Jun 30, 2006

I need to create a new column where I subtract one column by another.
I've been looking fo that for a while now, can someone explain how to do this?

View 7 Replies View Related

Math Functions

Mar 31, 2006

Hi,How to find the list of SQL math functions in SQL Server 2005?ThanksKai

View 2 Replies View Related

Math Error

Nov 23, 2006

select convert(float,'1.2334e+006')1233400.0select convert(decimal(20,2),'1.2334e+006')Server: Msg 8114, Level 16, State 5, Line 1Error converting data type varchar to numeric.can I set some options arithabort etc to have a workaround to thisproblem?Thanks.

View 3 Replies View Related

Math Notation In Db?

Dec 1, 2007

I'm not a professional dba or dbd, but I'm proficient in the basics ofdatabase design and sql. I want to create a database of mathdefinitions, and I'm wondering how one would go about creating adatabase that contains mathematical notation (and I'm not just talkingabout basic symbols where I could get away with ascii code). I needto be able to insert a wide variety of mathematical expressions, fromfractions to integrals, into fields (just like you can enter in-linemath symbols in MS Word using equation editor). I have no clue how togo about this. Is it a matter of developing certain programmingskills/languages? Would such a capabliltiy be proprietary (dbms-specific)? Is it possible at all? Any help would be appreciated.Thank you.

View 3 Replies View Related

Math Function

Jul 20, 2005

Hi AllI'm trying to find a math function (if it exists) in SQL Server. If itdoesnt exist, then maybe someone can tell me what its called so I cando a bit more reading on itBasically I want to do this:Parameter Components1 12 23 1, 24 45 1, 46 2, 47 3, 48 89 1, 8and so onI'd like to be able to call a function and it would return true orfalse like sofunctionname(1, 9) = trueso 1 is a component of 9functionname(2, 9) = falseso 2 is not a component of 9functionname(4, 5) = trueso 4 is a component of 5If anyone could tell me if it exists in C#, VB.NET, VB6 or VBScript,I'd appreciate it!Thanks in advanceSam

View 2 Replies View Related

Date Math

Jan 9, 2008

Below is my table layout, query, and results. I need to perform some date math to display how much time is elapsed between locations as patients are checked into each care_unit. I believe I could use the unique careunit_key but am not sure how to go about this.

[srm].[CDMAB_CAREUNITS]

[CAREUNIT_KEY] [decimal](37, 0) NOT NULL,

[EPISODE_KEY] [decimal](38, 0) NULL,

[CARE_UNIT] [char](20) NULL,

[ROOM_NO] [char](5) NULL,

[BED_NO] [char](5) NULL,

[DATE_IN] [datetime] NULL,

[TIME_IN] [char](6) NULL


select

cu.careunit_key,

cu.care_unit,

convert(nvarchar,e.ADMISSION_DATE, 101) as Admit_Date,

convert(nvarchar,e.EPISODE_DATE, 101) as Discharge_Date,

convert(nvarchar,cu.date_in,101) as date_in,

substring(cu.time_in, 1,5) as time_in,

convert(nvarchar,cu.date_in,101) +

convert(datetime,substring(cu.time_in, 1,5)) as date_time_in

FROM srm.episodes e

inner join srm.CDMAB_CAREUNITS cu on cu.episode_key = e.episode_key

inner join srm.item_header ih on ih.item_key = e.episode_key

inner join srm.patients p on p.patient_key = ih.logical_parent_key

where e.account_number = '11111777777'














CAREUNIT_KEY
CARE_UNIT
ADMIT_DATE
DISCHARGE_DATE
DATE_IN
TIME_IN
DATE_TIME_IN

1488831
3
12/10/2007
12/11/2007
12/10/2007
3:00
12/10/07 3:00

1498258
S4C
12/10/2007
12/11/2007
12/10/2007
5:54
12/10/07 5:54

1498406
SREC
12/10/2007
12/11/2007
12/10/2007
11:05
12/10/07 11:05

1498472
S6W
12/10/2007
12/11/2007
12/10/2007
12:37
12/10/07 12:37








View 3 Replies View Related

Doing Math With Cells

Apr 19, 2007

Good day all

Does anyone know if there is such a quary that can be written which would add up(or any math functions) a line of cells (on different rows) similar to that of working with a excel document?

If so please steer me towards the correct syntax for this.

Regards

Rob

View 1 Replies View Related

Date Math

Mar 12, 2008

Hi,

I have a column coming from DB2. It is the time is stored as 6 decimals of a second. So the value I got coming in is 44846(DT_I8), which needs to be divided by 60 to get minutes (747 minutes remainder 26 seconds). Then divide 747 by 60 to get 12 hours remainder 27 minutes. Thus the time is 12:27:26.

I have got a dervived column doing (DT_R8)(SUBSTRING((DT_WSTR,8)PSCCLOGTIM,1,5)) / 60 but the answer I am getting out is 747.433333. Close, but not close enough. Now I assume my problem has something to do with the Math being done on actual numbers not Time based numbers.

Anyone got any ideas on where I am going wrong and what the expression should look like?

View 11 Replies View Related

SQL Math Functions With COUNT() - Can Anyone Help, Please?

Mar 28, 2007

I have been trying to make a database that counts up and down votes (like eBay ratings or reddit votes).  I think (hope) I have got the database design right.
I know that you can perform math functions in SQL, but I want to use two COUNT()s from the same table and subtract one (the down votes) from the other (the up votes).
I have been learning ASP.NET 2.0 and it's going well, but I really need help with this.  I asked a question on this forum before and the answers were great and really helpful.
If anyone can help that would be great.  Thank you.
Jack.

View 3 Replies View Related

Performing Math Problem

Nov 19, 2003

I need to perform some division on the results of two alias columns that perform counts in a query. What is the best way to do this?

View 7 Replies View Related

Math Is Driving Me Nuts

Jul 20, 2005

The business rule is, the sales manager is commissioned on the avg. numberof appointments set up per salesrep per day during the month.I have 2 tables: The UserLog table records only 1 entry per day per user(salesrep). This will log how many salesreps worked a particular day. Thesecond table logs any appointments set up.UserLog: ID, UserName, EnteredTimeAppointment: ApptID, EnteredTime, ApptDateI figured that, for a given date ranged, I could1. sum the number of appointments2. sum the number of days worked2. sum the salesreps / number of days = avg number of salesreps per day3. number of appointments / avg number of salesreps per day = avg numberof appointments per sales repBut this logic is flawed. If I average out every day and then take anaverage of this daily average, I get a different result. Any ideas on howto best solve this problem?Thanks.

View 7 Replies View Related

Math - Division Question..

Dec 6, 2007

To set the stage, Tables are set up as such for this question:
-----------

Table: Answers
ID - Integer - Auto
Answer - Integer
QuestionID - Integer - FK from the QuizMaster table
StudentID - Integer - FK from the Students table

Table: QuizMaster

ID - Integer - Auto
Answer - Integer

Table: Students
ID - Integer - Auto
StudentName - Varchar(50)
----------
I would like to have an either a sql statement (1st) or a stored procedure (2nd) that would give me the percent correct for each student on the test.

In Access I could cheat and use this:



Code BlockSELECT Students.StudentName,
Count(Students.StudentName) AS TotalCorrect,
(SELECT Count(QuizMaster.ID) FROM QuizMaster;) AS TotalQuestions,
([TotalCorrect])/([TotalQuestions])*100 AS PercentValue
FROM (Answers INNER JOIN Students

ON Answers.StudentID = Students.ID)
INNER JOIN QuizMaster
ON (Answers.Answer = QuizMaster.Answer)
AND (Answers.QuestionID = QuizMaster.ID)
GROUP BY Students.StudentName
ORDER BY Students.StudentName, PercentValue;

Which is composed of the following...







Code Block

SELECT Students.StudentName,


Count(Students.StudentName) AS TotalCorrect
FROM (Answers INNER JOIN Students

ON Answers.StudentID = Students.ID)
INNER JOIN QuizMaster
ON (Answers.Answer = QuizMaster.Answer)
AND (Answers.QuestionID = QuizMaster.ID)


GROUP BY Students.StudentName;


SELECT Count(QuizMaster.ID) AS TotalQuestions
FROM QuizMaster;


([TotalCorrect])/([TotalQuestions])*100 AS PercentValue


But... that wont fly in SQL Server...What would work without using temp tables?
What would be the EASIEST way to do this?

Another way someone suggested is:




Code BlockCREATE PROCEDURE GetStudentGradeByID @StudentID Integer

AS

BEGIN


DECLARE @TotalQuestionsAsked as Integer;
DECLARE @StudentName as VarChar(50);
DECLARE @QuestionsCorrect as Integer;
DECLARE @PercentCorrect as Float;

set @TotalQuestionsAsked = select COUNT(*)FROM QuizMaster;
set @StudentName = select StudentName from Students where ID = @StudentID;

set @QuestionsCorrect = select count(Answers.ID) from Answers LEFT JOIN QuizMaster on Answers.QuestionID = QuizMaster.ID where StudentID = @StudentID AND QuizMaster.Answer = Answers.Answer;
set @PercentCorrect = (CAST (@QuestionsCorrect AS FLOAT) / CAST (@TotalQuestionsAsked AS FLOAT)) * 100.0;

select @QuestionsCorrect as TotalCorrect, @StudentName as Student, @TotalQuestionsAsked as NumQuestions, @PercentCorrect as CorrectPct;

END


But I need this as a datasource for a datagrid that would show all students etc... so using a parameter isn't really what I want.
So... could a stored procedure work for this?

View 14 Replies View Related

Please Help Me W/ My Query, Simple Math!

Jan 29, 2008

hi,

declare @query1 varchar(1000)
declare @query2 varchar(1000)
set @query1 = 'select count(*) from table1'
set @query2 = 'select count(*) from table2'

select @query1 - @query2

basically, i want to show the difference of this 2 select statements.. how do i do it?

thanks in advance!

View 5 Replies View Related

Interesting Math In A T-SQL Query

Oct 2, 2007


The value in the table of one DB is 17869 sq. ft. Now to insert this value in a new table of other database the reporting basis is 1000 i.e I need to do 17869/1000 = 17.8 so I have to take the value as 18. Another thing to be kept in mind is the value in the new table should have leading Zeroes. If the value is 18 it should be displayed as 0000018 ( data type in new table is Varchar(7) and in old table char (9) ). What can be the best way to implement this??

View 8 Replies View Related

DDL Statements Should Be Applied To All 25 Servers

Aug 7, 2002

Hi All,
We have a development server and about 25 Production servers. Whenever we did any DDL modification to development, it should be applied to all 25 different servers. I am trying to find a way to apply the changes to these servers from Development server without going to each server and run the script. Is there any way I can automate this action. There is no replication in all these servers. Can you please advise me on how to do this. This is a high priority task i have been assigned and I would appreciate any comments asap.
Thanks in advance.

--Jay

View 1 Replies View Related

How Do I Tell What Hotfixes Have Been Applied To An Instance?

Aug 31, 2007



How do I tell what hotfixes have been applied to an instance?

Thanks

View 3 Replies View Related

Subset_filterclause Not Applied At The Subscriber

Nov 6, 2006

I am using merge replication between SQL Server 2005 and SQL Express. Some of the articles in my publication have filter conditions. Changes to subscription databases are being applied to the publication database without regard to these filters.

The easiest way to see this problem is to create a merge publication with a single table article with @subset_filterclause of '0 = 1'. Any inserts to the publication database will not be propagated to the subscription database, but inserts to the subscription database will be propagated to the publication database. Can this be right?

View 4 Replies View Related

Row Count AFTER Filter Has Been Applied.

May 7, 2008



Is there a way to get a count of all the rows (total) after a filter has been applied at the row level?

Ie. Revenue has 11 rows but once the 6 blank ones are filtered count the total number of rows. So it should return 5.

View 1 Replies View Related

Foreach Variable Cannot Be Applied

Apr 30, 2007

I have created a foreach container to capture values from a query and run a script for each line. For some reason though I can't get past the variable mapping.



The SQL Task that is linked to the Foreach container is somthing like this:

SELECT str1, str2, str2, nValue1, nValue2

FROM MyTable



In the SQL Task I've set the following

ResultSet = Full Result Set

Connection Type = OLE DB

Result Name = 0



I've created the following Variables with a Package scope



s1 as String

s2 as String

s3 as String

n1 as Double

n2 as Double



When I run the package I get the following errors

Foreach variable mapping number 4 to variable "User : : n1" cannot be applied

Foreach variable mapping number 5 to variable "User : : n2" cannot be applied



The data type of nValue1 and nValue2 in MyTable are both numeric(19,4)



In setting the variable types in the package it seems that the closest to numeric(19,4) would be double. Is this why it is failing? Is there any way around it? I just need to pass the variables which are numeric and have decimal places.



Any insight would be greatly appreciated.



Regards,

Bill

View 3 Replies View Related

Subscriptions Invalid After SP Applied

Aug 29, 2006

Hello,

I finished applying SP 1 to sql2k5. Under the replication monitor all of the subscriptions now look like [].databasename when they were originally [subscriber1].databasename. Under Mgmt Studio I see the subscriptions correctly. When I try and replicate I get the message "The subscription to publication 'pub_databasename has expired or does not exist." I have tried to reinitialize the subscriptions but it doesn't work. Is there a way to solve this without have to drop the subscriptions and add them again as I do not want to lose the changes that were made on the subscriptions. We are using merge replication. Thanks.



John

View 16 Replies View Related

How Is 4GB Max Database Size Applied?

Oct 11, 2006

Is the 4GB Database size calculated by totalling up the size of all the databases in an instance OR against each individual DB in an instance (e.g. you can have an unlimited number of DB each up to 4GB in size)?
TIA
Antony

View 3 Replies View Related







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