Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
csmith
Starting Member
2 Posts |
Posted - 2007-05-07 : 19:42:55
|
| I'm trying to help out a beginning DBA and come up with a SQL query. Here is the information I've been given so far."I have a SQL database (TEST1_new) with several tables. I need to have some values updated in one of the tables HARR2APP.CUSTOMER_ORDER_LINE_TAB1). I need the value that exists in the QTY_SHIPPED field to be divided by 250. I also need to include a WHERE statement for the PLANNED_SHIP_DATE greater than 11/15/2004 and a CATALOG_NO =18053185292 or 18053185285. Basically, what I need to do is take the value for QTY_SHIPPED for Catalog_NO 18053185285 & 18053185282 and divide the result by 250"After reading through her statement above about 10 times and guessing a bit, here's what I was able to come up with. I'm sure the syntax is not correct but maybe it's close to being what's needed? INSERT INTO HARR2APP.CUSTOMER_ORDER_LINE_TAB1()(SELECT dbo.TEST1_new.HARR2APP.CUSTOMER_ORDER_LINE_TAB.QTY_SHIPPED LIMIT 1) /250),PLANNED_SHIP_DATE from dbo.TEST1_new.HARR2APP.CUSTOMER_ORDER_LINE_TAB WHERE CATALOG_NO = ‘18053185292’ OR CATALOG_NO= ‘18053185285’AND PLANNED_SHIP_DATE > ‘11/15/2004’;Any help is greatly appreciated.Chris. |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-05-07 : 20:02:55
|
what does LIMIT 1 mean ?INSERT INTO HARR2APP.CUSTOMER_ORDER_LINE_TAB1( <column list>)SELECT (CUSTOMER_ORDER_LINE_TAB.QTY_SHIPPED/250),PLANNED_SHIP_DATE FROM dbo.TEST1_new.HARR2APP.CUSTOMER_ORDER_LINE_TAB WHERE (CATALOG_NO = '18053185292' OR CATALOG_NO= '18053185285')AND PLANNED_SHIP_DATE > '20041115' Dinakar NethiSQL Server MVP************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
Jeff Moden
Aged Yak Warrior
652 Posts |
Posted - 2007-05-07 : 22:54:40
|
| "LIMIT" is a term used in MySQL... Not SQL SERVER.--Jeff Moden |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-05-08 : 00:54:28
|
| Equal to TOP 1.Peter LarssonHelsingborg, Sweden |
 |
|
|
csmith
Starting Member
2 Posts |
Posted - 2007-05-08 : 11:54:36
|
| Thanks guys. This is great. |
 |
|
|
|
|
|