|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
How can I write into my sql script ORDERTOTAL is equal to wineorder.quantity * winelist.winename WHERE winelist. winename=wineinvoice.winename
CREATE TABLE "WINEINVOICE" ( "INVOICENO" NUMBER, "ORDERID" NUMBER NOT NULL ENABLE, "INVOICEDATE" DATE, "CUSTOMERNAME" VARCHAR2(50) NOT NULL ENABLE, "WINENAME" VARCHAR2(50) NOT NULL ENABLE, "QUANTITY" NUMBER NOT NULL ENABLE, "ORDERTOTAL" NUMBER, "PRICE" NUMBER NOT NULL ENABLE, CONSTRAINT "WINEINVOICE_PK" PRIMARY KEY ("INVOICENO") ENABLE, CONSTRAINT "INVOICEORDER" FOREIGN KEY ("ORDERID") REFERENCES "WINEORDER" ("ORDERID") ENABLE ) / |
|
#2
|
||||
|
||||
|
Usually I use two tables, one for the general data of the invoice ("INVOICENO", "ORDERID", "INVOICEDATE", "CUSTOMERNAME") and another one for the invoice details ("INVOICENO", "WINENAME", "QUANTITY") and I compute totals for each invoice with a view, something like:
select "INVOICENO", "ORDERID", "INVOICEDATE", "CUSTOMERNAME", sum("WINENAME" * "QUANTITY") from "invoice", "invoice details" where invoice.invoiceno = invoice details.invoiceno group by ... (this is all pseudo-code).
__________________
My blog about OpenSource Databases PDF tutorials about OSS databases, DBMonster ... Please contribute to Open Source Development, fill bug reports!!! Developer Shed eSupport Commented my.ini/my.cnf (PLEASE ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > multiplying values in oracle |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|