Default Value On Quantity And Price Field
Jun 1, 2006
should I set to "0" as a default value on a quantity and a price field
or set to "null"?
if a user enter nothing on the quantity or price field on a web
browser, should I treat it as null or "0"? I am so confused about this
concept. please advise me. thank you.
View 5 Replies
ADVERTISEMENT
Jun 19, 2000
I am developing basket and need a simple way to get price x quantity + total price.
I get back a recordset which has a varying number of items, each item has a price and quantity. Using
SELECT ((productprice)*(productquantity)) AS subtotal, product name, productid
I don't know how to add all subtotals to get a total, I have tried putting in SUM but but cant get it to work.
Any help would be well appreciated.
View 1 Replies
View Related
Feb 20, 2008
Hello all, I have an interesting question about calculating a price in my database for a quantity entered. I have a join table that I store ProductID, SizeID, Quantity and Price. The price for a particular product changes based most often on the quantity ordered. For example, if you order one unit of a widget the price is 10.00, however if you order one dozen units of the same widget the price drop to 9.75 and so on.
Here is a sample of my table....columns are in the order I specified above.
1, 1, 1, 10.00
1, 2, 1, 10.00
1, 3, 1, 10.00
1, 1, 6, 9.90
1, 2, 6, 9.90
1, 3, 6, 9.90
1, 1, 12, 9.75
1, 2, 12, 9.75
1, 3, 12, 9.75
1, 1, 24, 9.50
1, 2, 24, 9.50
1, 3, 24, 9.50
1, 3, 36, 9.30
1, 2, 36, 9.30
1, 1, 36, 9.30
So depending on if my widget is available in certain sizes, the second column, then each product has an price for the size id and quantity at which the price break occurs.
I use this stored procedure to return the price or price range based on the input parameters entered.
CREATE PROCEDURE dbo.sp_GetPrice
@ProductID INT,
@QuantityID INT = NULL,
@SizeID INT = NULL
AS
BEGIN
SET NOCOUNT ON
IF @QuantityID IS NOT NULL AND @SizeID IS NULL -- WE ARE L0OKING FOR A SPECIFIC PRICE BUT DO NOT HAVE A SIZE SPECIFIED
SELECT DISTINCT Price AS 'Price'
FROM join_ProductSizeQuantityPrice
WHERE ProductID = @ProductID
AND Quantity = @QuantityID
IF @QuantityID IS NOT NULL AND @SizeID IS NOT NULL -- WE WANT THE EXACT PRICE FOR THE SIZE AND QUANTITY SPECIFIED
SELECT Price AS 'Price'
FROM join_ProductSizeQuantityPrice
WHERE ProductID = @ProductID
AND SizeID = @SizeID
AND Quantity = @QuantityID
IF @SizeID IS NULL AND @QuantityID IS NULL
SELECT MIN(Price) AS 'Price Range' -- WE ARE LOOKING FOR A PRICE RANGE
FROM join_ProductSizeQuantityPrice
WHERE ProductID = @ProductID
UNION ALL
SELECT MAX(Price)
FROM join_ProductSizeQuantityPrice
WHERE ProductId = @ProductID
END
GO
So everything works great, however, when a user orders an quantity amount like 7, 13, 26 - which is not part of the table - I want to give them the discount available to them for the price break appropriate.
For example if a customer orders 16 widgets of size 2 the price break threshold they have crossed is one dozen, however they have not yet reached the next one which is two dozen. Therefore I want to offer the price associated with one dozen widgets of size id which is: $9.75. Once I have this a simple calculation of this price * 16 units would give me a total but my question is, how do I elegantly design this quantity / right price per unit calculation?
-Brian
View 9 Replies
View Related
Sep 20, 2007
I'll give a basic example of my table.
OrderID, ProductID, Quantity
1,1,4
I would like to display the above row 4x (hence qty of 4)
1,1,"item 1"
1,1,"item 2"
1,1,"item 3"
1,1,"item 4"
Any suggestions? Thanks.
View 7 Replies
View Related
Nov 13, 2006
Does anyone have any ideas on how I can superscript a price field in a RS 2000 Report? I need the cents to be superscripted and underlined. I didn't want to use two text fields if possible. Is it possible do do something like this <sup>$</sup>99<u><sup>99</u></sup> ?
View 1 Replies
View Related
May 8, 2015
I need sql query to select max date shipment where sum of quantity required > sum of quantity shipped from sales line table but i dont know how to make my sales line table as following
shipment date quantity required quantity shipped
07/05/2015 200 100
07/05/2015 300 300
07/05/2015 100 50
06/05/2015 200 100
06/05/2015 200 200
Here the result of query i need is max shipment date is 07/05/2015 and quantity required is 600 and quantity shipped is 450 so tat i must select this date because quantity Required is big from quantity shippedmy question How i write the query get result above in sql server 2005.
View 9 Replies
View Related
Dec 12, 2014
I have to add the unit price on the order acknowledgement for products on our shelf.
Each product has different price breaks stored in a table called MaterialUnitCost.
I don't know how to pull the correct price based on the order quantity.
Let's say the customer orders 200 pieces,
I sell 1 pcs @ $20
50 pcs @$15
200 pcs @$10.
My order acknowledgement should pull a unit price of $10, but it pulls $20 instead, because in my select statement I have
select materialunitcost.unitcost.
I thought I should do a loop or use the row_number function, but I am new to SQL, and I never used any of these two.
View 1 Replies
View Related
Sep 30, 2015
I have a robust query that returns a dataset and the data is good, however some of the records contain the exact same data with the exception of the 'Price' field. I want to combine the records that are identical and SUM the values in the 'Price' field. My query and example return dataset is below.
Query:
--------
select distinct
'On-Demand' as 'Business Line',
o.OrderID as 'Order #',
isnull(d.DisplayCode,'UNK') as Hub,
isnull(rz.RouteID,'UNK') as 'Default Route',
'On-Demand' as 'Assigned Route',
[Code] ....
View 4 Replies
View Related
Nov 18, 2014
I have 2 tables: Order(ID, Quantity) and Product(ID,Name, Price) and I want to add a calculated field in Order table based on the price column in the Product table. How do i do that?
this query returns the values i want in the table.
select a.quantity * b.price
from tblCustomerPurchases as a
join tblProduct as b
on a.ID=b.ID
View 17 Replies
View Related
Oct 30, 2006
Hi All,
I need to create a new field on a table and have that field default to another field value in that same table. Is there a way to do this w/ a default constraint rather than adding a trigger to the table? If i can't use a default constraint does anyone have a template trigger i could use? Below is an example of what i'm trying to do (Field_C is the new field and i want it to use Field_A value if no other value is specified on insert). Any help would be greatly appreciated.
alter table FOO add Field_C varchar(50) not null constraint FOO_default DEFAULT Field_A
thanks,
Dave
View 1 Replies
View Related
Aug 13, 2013
My dataset looks like this:
IDBuyDotComPriceCompanyIDShadowOf
AB CIRCLE PRO199.99203
AB CIRCLE PRO-b2199.99203AB CIRCLE PRO
AB CIRCLE PRO-TB249.99344AB CIRCLE PRO
AB CIRCLE PRO-TB-S10344AB CIRCLE PRO
I need to update the price of an item where the CompanyID is 344 and the ShadowOf is not null. The value in ShadowOf is the same as the ID that I want to get the BuyDotComPrice for. It should be simple, but I keep getting errors.
I use Microsoft SQL 2008
View 1 Replies
View Related
Jun 15, 2004
Is it possible to change the default value of a field using a stored proc or query? Any hints on how to do this if it is possible would be appreciated!
Mike B
View 1 Replies
View Related
Jul 9, 2007
I'm copying MyDbTable to TempdbTable. There are 12 fields and I'm ignoring 11 of them when copying the one table to another with DTSWizard.
Once the TempdbTable is there, I'm adding 2 fields along with the one that is there already.
1) field1 int, Nullable, Default value ((3))
2) field2 tinyint, Nullable, Default value ((1))
The reason why I'm creating these two fields and giving them a value so they will match up when I import TempdbTable to MyDb2ndTable.
The problem I'm having is... field1 and field2 have a Null value intead of the value I'm giving them.
I'm new at this, so maybe the cause of the problem is obvious, but if anyone can help me I'd really appreciate it.
Thanks,
Bill
View 21 Replies
View Related
Mar 25, 2008
hi, please help me, i have a data driven site, i made a field that i call "Status"so this is how it should happens, there are three different gridviews in a single page, gridview1 filter is [status] = ok, gridview2 filter is [status] = fine, gridview3 filter is [status] = complete, so all gridview has its own <asp:hyperLinkField> at first the value of "Status" is ok, so it will appear in the gridview1, so when the user click on the <asp:HyperLinkField> of gridview1 it will go to a new page with a form view, this page has a button that when click will change the value of the status field to "fine", so that it will no longer appear to the gridview1 but it will now appear to gridview2 and same with the next <asp:HyperLinkField> click until it appears to the final gridview. so my question is how can i make the button that is capable of changing (update) the value my database field (status) to a specific value, that is not visible to the user thru codebehind or plain asp.net codes. please help me, if you need more info just reply.ThanksSALAMAT PO!
View 1 Replies
View Related
Jul 6, 2004
Hello,
Can I simply set the default value of a dateTime field with the date and time that the record was created?
View 2 Replies
View Related
Nov 7, 2007
I am doing a shopping basket type demo.I have difficulties going from table with fields like (Name,ProductCode) to table(Name, ProductCode, NumberOfItems). One way could be adding just Name and ProductCode fields and let NumberOfItems come automatically. It could have some common value like 1. How should I do this with VB.
View 1 Replies
View Related
May 25, 2004
In SQL Server 2000 / Asp.Net I am trying to use default values for all fields; hoping to eliminate nulls.
For number and character fields, the default is pretty obvious, but is there any empty value for a date field? I think a null there might be better than putting in a bogus date, at least it can be tested for.
Are there any more developend ideas on this question?
Many thanks
Mike Thomas
View 1 Replies
View Related
Jan 28, 2008
Hello,
I am trying to write an SQL command to set the default value of an integer column I have within a table.
ALTER TABLE TableName alter column ColumnName int default 0
Any suggetions?
View 3 Replies
View Related
Nov 7, 2007
I am creating a new filed in SQL Server 2005, and I want the field to have the default of '0'
I select the data type as numeric and save my changes, I then visit our front end database to see if the default value is just '0' but it appears as '0.00'
SO i thought about changing the default value to int (im thinking this means integer?) and changing it to '3' but it still displays the decimal point and two 0's
Am I doing something wrong here? I just want it to display '0'
Thanks
View 12 Replies
View Related
Aug 4, 2006
We want to add a default date to our database tables. Looking at other database samples people use all sorts of dates to add as default date e.g. 1/1/1997 or the getdate() function.
Is it good practice to set a default date and what should the default date be????
Newbie
View 2 Replies
View Related
Aug 10, 2006
I am working with a SQL server 2005 database. I have created several new tables. In one of the tables, I need to set up a data field so that it will default to a particular value. For exampe, I need to have a particular data field default to a value of '0'
How can I do this? I would prefer not to do this through Query analyzer. I have been using the interface to SQL server 2005 provided through the Visual Studio IDE.
Thanks in advance, Bill
View 1 Replies
View Related
May 17, 2008
Is there a way to set a field value to the column default in an update statement?
Eg.
UPDATE Table2 SET field1 = DefaultValue
where DefaultValue is the field1 column default in the table definition.
The reason I need to do this is when I delete a record from Table1, I need to set the foreign key in Table2 to the default (I don't want to delete the record in Table2, just want to set the key to a default key). I could hard-code the default value in the stored procedure but I think that's just not clean. If I create a new instance of the DB and the default value changes, I'd need to change the stored procedure(s). Just not clean...
To avoid a drawn-out discussion, there are reasons why I can't setup a relationship between the two tables and use "ON DELETE SET DEFAULT".
Any info greatly appreciated.
View 9 Replies
View Related
Oct 13, 2005
hi
I have a field call: password, I want to generates some random chars as
default password for users (so user got something to login, and update
later).
Current Solution I have:
I made myself a trigger and it does generate password on insert, but
the problem with that is I have to allow NULL on that field. I
don't want NULL to be allowed, and if I don't allow null... sql server
won't allow me to insert a record (when leaving password field empty).
Reason i don't wanna allow NULL on that field, is because there may be
more applicaions using the same field from the same database.
Just in case if the other developer gets sloopy, I don't want other
application(s) allow user put to enter a null or leave it blank on my
password field.
My question is:
1) can I put a function or some sort at the "Default" field under "Design Table", if so...how?
2) any suggestions for a better implementation?
3) if (1) doesn't work, what other options would you suggest other then the current trigger i'm using?
TIA
View 5 Replies
View Related
Jul 20, 2005
There are two tables, parent and child table.Foreign key field of the child table is not a required field. If thedata is submitted w/o a value into the foreign key field, what shouldI make it as a default value? Should it be "null"?
View 2 Replies
View Related
Jul 16, 2006
I have a datatable : Data_Table and a look up table: Lk_table. Myfield that I
use in Inner Join is defined in both the
data and look table.
So I build my query like this:
SELECT * FROM dbo. Data_Table INNER JOIN
dbo. Lk_table ON dbo.Data_Table.MyField = dbo.Lk_table.Myfield
The pb, sometimes I
have myfield still with its default null value in the datatable: Data_Table.
So, I end up getting 0 record when I execute the query shown above.
How do I turn that around so that even if myfield in Data_Table
is Null, I still get the records from Data_Table. (I don t want a set of
records including all possible values from the look up table: Lk_Table)
View 2 Replies
View Related
Mar 5, 2008
SELECT ArticleID, ArticleTitle, ArticleDate, Published, PublishDate, PublishEndDateFROM UserArticlesWHERE (ArticleDate >= PublishDate) AND (ArticleDate <= PublishEndDate)
When I use the above on a GridView I get nothing. Using SQL manager it works great.
I don't know how to pass the value of the ArticleDate field as a default parameter or I think that's what I don't know how to do.
I am trying to create a app that I can set the dates an article will appear on a page and then go away depending on the date.
Thanks for any help!
View 1 Replies
View Related
Apr 12, 2008
I am converting an Access 2003 database into SQL 2005 Express for purposes of evaluating the SQL server environment as a future home for my data. One of the motivating factors in the conversion is the integration of LINQ with VB 2008.
Assuming that there was no conversion tool to migrate Access forms for use with SQL and VB 2008, I converted the Access data table and used the VB 2008 form designer to databind textbox controls to fields in the converted SQL database. Here are some basic questions:
The conversion from Access to SQL apparently did not include the default numeric formatting (currency, percentage, etc.) which was part of the Access data table. Is there a place in the SQL server environment to supply a default data format so that forms and reports referencing the field do not need to be manually formatted for each reference?
After converting the data table and spending 2 hours designing the dataform for the 80+ fields, I inadvertantly changed the table structure and found that the dataform was not happy (oops). I corrected the databindings manually for the few errant field references, but wonder if there is some wizard to do this automatically?
Is there a way to print out the dataform itself? I used the following code snippet in my Access form code-behind and I wonder if there is an equivalent VB 2008 function:
Code Snippet
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection
Finally, Access can instantly change from dataform to datasheet presentation screens. Can this be done in VB 2008 with two views simultaneously presenting the same SQL data?
Please excuse my naivete, but in contrast to Access 2003 where program functionality is encapsulated into readily apparent controls, menus, and dialogs, the SQL server environment seems foreign, spartan, and all the words are different. Thanks, -BGood
View 3 Replies
View Related
Aug 14, 2007
I have following table structure
CREATE TABLE [dbo].[EMPLOYEE] (
[REC_ID] [int] IDENTITY (1, 1) NOT NULL ,
[EMP_ID] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[NAME] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PROJECT_ID] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[LOGIN_ID] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[PPE_STOCK] (
[REC_ID] [int] IDENTITY (1, 1) NOT NULL ,
[PPE_ID] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[PPE_NAME] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[QUANTITY] [int] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[PPE_ITEM_ISSUE] (
[PII_ID] [int] IDENTITY (1, 1) NOT NULL ,
[EMP_ID] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[DATE_REQUEST] [datetime] NULL ,
[QUANTITY_ISSUE] [int] NULL ,
[DATE_ISSUE] [datetime] NULL
) ON [PRIMARY]
GO
I want to calcalate the balance quantity avaiable in the stock.
PPE_STOCK => STOCK OF QUANTITY TABLE
PPE_ITEM_ISSUE => STOCK QUANTITY ISSUE TO EMPLOYEE TABLE
query retrieve like this.
Name....EMP_ID....PPE_NAME,..QUANTITY_ISSUE.Stock Qty.Balance Qty
-----------------------------------------------------------------
Martin..p0012456..Safety Gloves 1 .......100........99
Martin..p0012566..Safety Glass 1 .......100........99
Peter...p00123456.Safety Gloves 1........100........98
Jone....p00987654.Safety Helmet 1........100........99
Khan....p0012122..Safety Helmet 1........100........98
....
stock quanity minus the issue qauantity and retreive balance QTY
how ?
How can calcuate / retrieve the balance quantity by the query ?
Please us query calcuation.
regards
Martin
View 3 Replies
View Related
May 16, 2008
When a user orders an amount of a given product, I want to update the available quantity in my db. I use a loop to insert each ordered product item and the needed quantity into an ORDERED_ITEMS table (these items are tied to an order record in another table). The available_quantity is in the STOCK table. Here is my code. Can you help me out with how I can achieve this? (I know my queries should be in SP's, but for now while I'm getting everything the way I want it, it's easier to write it directly in my code.)
Thanks!
//insert the individual items
string items_to_ship = "";
foreach (GridViewRow rw in GridView1.Rows)
{
if (rw.RowType == DataControlRowType.DataRow)
{
if (((TextBox)rw.Cells[4].FindControl("qtyneeded")).Text != "")
{
int qty = Convert.ToInt32(((TextBox)rw.Cells[4].FindControl("qtyneeded")).Text);
int itm = Convert.ToInt32((rw.Cells[0].Text));
SqlConnection mycn2 = new SqlConnection(myConnectionStr);
SqlCommand myCommand4;
SqlDataReader rdr = null;
int new_qty = 0;
myCommand4 = new SqlCommand
("INSERT INTO SHP_ORDERED_ITEMS (ship_id, item_id, quantity) values(@ship_id,@item_id,@quantity);" + "SELECT item_description, qty_available from shp_stock where item_id = @item_id;", mycn2);
myCommand4.Parameters.Add("@ship_id", SqlDbType.UniqueIdentifier).Value = shipmentID; myCommand4.Parameters.Add("@item_id", SqlDbType.Int).Value = itm;
myCommand4.Parameters.Add("@quantity", SqlDbType.Int).Value = qty;
myCommand4.Connection.Open();
rdr = myCommand4.ExecuteReader();
while (rdr.Read())
{
// create a list of item descriptions and quantities of each, for use in the email
items_to_ship += (string)rdr["item_description"] + " (" + qty.ToString() + ")<br>";
}
myCommand4.Connection.Close();
}
}
}
View 1 Replies
View Related
May 18, 2004
Quantity of entrys from record set
Hi All!
In a database (Access) i have many lines. In one of colomnes (Label) i have entrys "AAA", "BBB", "CCC", ... . I would like to know how many "AAA" and
how many "BBB" we have in database.
Is this possible to achieve this by using i = RecordSet.Fields (Label). ... mixad with other functions where i is an integer and RecordSet a record set?
what a SQL query cal deliver a i as
Integer, where i is quantity of lines
labeled with "AAA".
How can i do this with VBA?
Thank You all!
Alexander
View 1 Replies
View Related
Jan 3, 2013
currently we have some shipping software that has a mqsql database locally.There are filters on the program and when an item is shipped from our warehouse it goes into a filter "Shipped".We have a SKU and also quantity for the product.
Now we have an inventory program that also has a mqsql database,this has the same SKU as the shipping software database.what we hope to do is when an SKU is shipped in our software program(ie it Goes into the "Shipped" folder),it will deduct the quantity from the adjacent SKU in the inventory program database.
Note that the 2 databases are independent from each other but would like them to be in effect linked to each other.
View 1 Replies
View Related
Aug 20, 2013
I am trying to query only the Max date dependant on quantity
Create Table dbo.TestParts
(Part char(30), Desc1 char(50), Desc2 char(50));
Create Table dbo.TestStructure
(Model char(30), Part char(30), EDATE smalldatetime, QtyPer float);
GO
Insert INTO dbo.TestParts Values('101111','Widget A', 'Batteries Not Included'),
[Code] ....
Looking for a return of:
PART Description EDATE QtyPer
101112 Widget B ..... 2012-12-03 3
101113 Widget C ..... 2012-12-03 5
101114 Widget D ..... 2012-12-01 1
Widget A should not show because the last date the qty was changed to Zero
Closest that I have come..........(which is pulling the part 101111 which should be incorrect)
Select ts.Part, RTRIM(tp.Desc1) + ' ' + RTRIM(tp.Desc2) as Description,
ts.EDATE, ts.QtyPer
FROM testing.dbo.TestStructure ts
Inner Join (Select Part,MAX(EDATE) as Date
FROM testing.dbo.TestStructure
WHERE QTYPER <> '0'
[Code] .....
View 3 Replies
View Related
Nov 8, 2014
I have a table Item_used like this
Itemname Employee Quantity
pencil samlopez 10
pencil samlopez 5
All I want is to make a report that sum all the quantity of the same items with the same employee like this
Itemname Employee Quantity
pencil samlopez 15
View 1 Replies
View Related