由买买提看人间百态

topics

全部话题 - 话题: orderid
1 (共1页)
m**********2
发帖数: 2252
1
有个table,有3个columns。一个是客户ID,一个orderID,一个orderdate。每一个
order就有一个orderID。比如客户ID 500,会有orderID 201,302,809. 客户ID 600
,会有orderID 211,298,344。
现在我想在这个table加一个column,ordersequenceID,比如客户ID 500,根据
orderID的大小,如果orderID是201,就是1,orderID是302,就是2,orderID是809,就
是3. 同样,比如比如客户ID 600,根据orderID的大小,如果orderID是211,就是1,
orderID是298,就是2,orderID是344,就是3。
这个应该怎样做?
谢谢。
B*****g
发帖数: 34098
2
should be sql server as table name is [Order]
But when I count ( and ), there are 2 ( and 3 ), can not believe it can
compile.
SELECT
OrderID
, CustomerName
, RowNumber =
(SELECT COUNT(*)
FROM [Order] b
WHERE b.OrderID = a.OrderID
AND b.ProductID < a.ProductID)
FROM [Order] a)
GROUP BY OrderID
ORDER BY OrderID
P********R
发帖数: 1691
3
Oracle trigger procedure中生成的数据如何送到stored procedure中?
表orderitems有四列:orderid, detail, partid, qty.
比如在主程序中接收三个变量:
v_Orderid ORDERS.orderid%TYPE := &2;
v_Partid INVENTORY.partid%TYPE := &3;
v_Qty ORDERITEMS.qty%TYPE := &4;
然后用:
AddLineItemSP(v_Orderid, v_Partid, v_Qty);
语句激活stored procedure并将三个值赋给i_Orderid, i_partid, i_Qty:
CREATE OR REPLACE PROCEDURE AddLineItemSP (
i_Orderid IN ORDERITEMS.orderid %TYPE,
i_Partid IN ORDERITEMS.partid %TYPE,
i_Qt... 阅读全帖
s******e
发帖数: 285
4
来自主题: JobHunting版 - 一个简单的SQL查询题
这个和第一个表根本没关系啊
SELECT orderid, count(*) AS freq
FROM order
GROUP BY orderid
ORDER BY orderid
b*****e
发帖数: 364
5
SELECT a.ID, a.ORDERID, MIN(a.orderdate-b.orderdate) as DateDifference,
COUNT(b.orderID)+1 as OrderSequence
FROM Table a
JOIN Table b
ON a.ID=b.ID
WHERE a.orderdate>b.orderDate
GROUP BY a.ID, a.ORDERID;
q*c
发帖数: 9453
6
终于放假了, 你们这些单机党也太猖獗了。 有点时间给你们个堆机器版的。 不过时
间很少所以剩余的自己脑补。
老魏你说的能达到你的单机版的 1/10 就了得了,你的也就几M/s. 你看看我这个版本。
用的全是 proven technology. 有点经验的一看就知道肯定能 work. 全套卖票。
当然你也说了, 我这个酒不需要实现了, 因为比较麻烦。 不过你看看就知道肯定无
问题
实现的和你那个功能完全一样。
前段, 无状态的 web server. 接受订票. 受到订票直接转到相应的中间集群。
中间, 是按照用户 id hash 的 用户数据库群 + 用户 controller.
收到订单然后在数据库中产生该用户的订票信息. 比如有三张连票,
userid, orderID, start1, end1, status = processing
userid, orderID, start2, end2, status = processing
userid, orderID, start3, end3, status = processing
后端, 是按照车次hash ... 阅读全帖
e****2
发帖数: 2723
7
来自主题: Chemistry版 - CODE,并不难学
最近我写的数据库CODE
与民共享
Create view vw_order_cost as
Select o.orderid,o. orderdate, d.productid, c.companyname, (d.Quantity
* d.UnitPrice) as cost from orders o join orderdetails d on o.orderid=d.
orderid
Join customers c on o.customerid=c.customerid
o********8
发帖数: 5
v***s
发帖数: 1893
9
来自主题: Database版 - 请教数据库设计的问题
举个例子
table1 userid infomation
userID (PK)
...
table2 order information
orderID (PK)
userID (FK)
....
table3 order detail
OrderDetailID (PK)
orderID (FK)
goodsID (FK)
....
一个人可以有N个orders, 一个order可以有N个商品。
这样三层搞下来table3就是个有很多很多的行大表格。如果是amazon这样的网站,几亿
行都在一个大表格内,query怎么办?
是从数据库设计方面去优化,还是从数据库软件和硬件方面去考虑?
c*****d
发帖数: 6045
10
In Oracle, it should be,
select orderid,customername,
rank() over(partition by orderid order by customername)
from "order" ;
a*******t
发帖数: 891
11
OK, here is a full working example:
CREATE TABLE [dbo].[testing](
[OrderID] [varchar](50) NULL,
[CustName] [varchar](50) NULL
)
and then insert some sample data into the table
123, John
567, Joe
123, Mary
123, Peter
and then here is the query
select
OrderID
, max(case rowno when 0 then CustName end) +
coalesce(max(case rowno when 1 then ', ' + CustName end), '') +
coalesce(max(case rowno when 2 then ', ' + CustName end), '') +
coalesce(max(case rowno when 3 then ', ' +
c*****d
发帖数: 6045
12
你还是没看明白我上面说的
不管用户执行insert INTO ORDERITEMS (orderid,partid,qty)
还是insert INTO ORDERITEMS (orderid,detail,partid,qty)
或者说不管用户有没有提供detail
trigger都要忽略detail,然后改用max+1
不用trigger返回任何value
P********R
发帖数: 1691
13
来自主题: Database版 - Transact SQL问题请教
得到一出错信息如下
Msg 8144, Level 16, State 2, Procedure AddLineItem, Line 0
Procedure or function AddLineItem has too many arguments specified.
/* EXECUTE代码如下:*/
EXECUTE AddlineItem @vOrderid, @vPartid, @vQty, @vStr OUTPUT;
IF @vStr = 'Insert failed'
BEGIN
PRINT 'Insert failed'
PRINT 'FAILURE';
RETURN;
END;
ELSE
PRINT 'Insert successed!'
-- ENDIF;
PRINT 'SUCCESS.';
END;
/* the AddLineItem代码如下: */
IF EXISTS (SELECT name FROM SYS... 阅读全帖
m******u
发帖数: 12400
14
来自主题: Database版 - what does the question mean?
谢谢楼上两位,你们的理解是对的,一个orderid(一个order)可以有多个productid
(多个product)
只有orderid和production 1对1 对应的才是single-item order。
c*****d
发帖数: 6045
15
a.orderID肯定不能出现在group by里,如果orderID是不重复的
w****w
发帖数: 521
16
select CustomerID
from (
select a.CustomerID,a.OrderDate,a.SalesOrderID,COUNT(b.OrderDate) Cnt
from [Sales].[SalesOrderHeader] a join [Sales].[SalesOrderHeader] b
on a.CustomerID=b.CustomerID
where DATEDIFF(day,a.OrderDate,b.OrderDate) between 0 and 10
group by a.CustomerID,a.OrderDate,a.SalesOrderID
) c
group by c.CustomerID
having MAX(Cnt)>=5;
The key is for each order, count the number of orders in next 10 days.
OrderID here is for order identification, otherwise o... 阅读全帖
c*****d
发帖数: 6045
17
a.orderID肯定不能出现在group by里,如果orderID是不重复的
w****w
发帖数: 521
18
select CustomerID
from (
select a.CustomerID,a.OrderDate,a.SalesOrderID,COUNT(b.OrderDate) Cnt
from [Sales].[SalesOrderHeader] a join [Sales].[SalesOrderHeader] b
on a.CustomerID=b.CustomerID
where DATEDIFF(day,a.OrderDate,b.OrderDate) between 0 and 10
group by a.CustomerID,a.OrderDate,a.SalesOrderID
) c
group by c.CustomerID
having MAX(Cnt)>=5;
The key is for each order, count the number of orders in next 10 days.
OrderID here is for order identification, otherwise o... 阅读全帖
f**********w
发帖数: 93
19
来自主题: Quant版 - limit order book的存储
I was askes a similar question, I gave the following data structure,
enum OrderType { BUY, SELL};
struct OrderInfo
{
// order information
double price;
OrderType ot;
int shares;
};
struct PriceComparator{
// compare OrderInfo based on price
bool operator() (const OrderInfo& lhs, const OrderInfo& rhs)
{
return lhs.price > rhs.price;
}
};
use hash_map to look up stockname from
orderId;
then use
hash_map
w*******y
发帖数: 60932
20
Sony 32" S Series is on Sale at sonystyle for $399. Following are the
details.
Link:
http://www.sonystyle.com/webapp/wcs/stores/servlet/SYOrderItemAddProxy?catalogId=10551&storeId=10151&langId=-1&partNumber=KDL32S5100/BSTOCK&orderId=.&quantity=1&URL=OrderItemDisplay?orderId=.&mode=add
1. Sony S Series Bravia
2. Next lowest (for used) on Google products is $447.00
3. Model is KDL 32S5100
4. 3 HDMI, 2 component and 1 PC, 60Hz
Please be easy this is my first post.
i****k
发帖数: 4085
21
来自主题: Military版 - 国内多家银行否认用户资料外泄
用户信息的安全性似乎真出了问题,昨日“泄露门”又有了升级版。在“天涯被黑”
、“当当(微博)网用户资料泄密”事件之后,昨日,挨踢客网站上再爆猛料,有网友提
供消息称,多家银行用户资料外泄。随后,涉及到的银行均对此事予以否认。
涉及银行齐否认
“这纯属谣言”。该消息中所涉及到的银行随后均发布澄清公告,并异口同声地表
示,经核查,网站上贴出来的用户信息均属伪造。
挨踢客提供的消息显示,国内多家银行的用户数据已经泄露,其中交通银行(4.48,
0.02,0.45%)7000万、民生银行(5.89,0.07,1.20%)3500万。该网站称无法核实数据的真
实性,但贴出的截图显示,泄露数据的银行包括交通银行、民生银行、工商银行(4.24,
0.04,0.95%)等,数据包含了用户的姓名、卡号、密码等敏感信息。
工行相关负责人表示,网上贴出的所谓泄漏用户数据中所涉及的三张该行银行卡均
为已注销的无效卡,且其中包含了订单号(OrderId)等内容,可以判断信息不是来自银行
数据库。
此外,交通银行发布声明表示,将保留追究散步谣言者法律责任的权利。
“安全U盾”已不安全?
虽然各家涉及到的银行均对此... 阅读全帖
e***l
发帖数: 6493
22
来自主题: ebiz版 - 爆 亚麻 EVIL
顺便扒一扒:
https://www.amazon.com/sp?_encoding=UTF8&asin=B019THRJZI&isAmazonFulfilled=0
&isCBA=&marketplaceID=ATVPDKIKX0DER&orderID=&seller=AKLQ5RQWS61BD&tab=&
vasStoreID=
http://fakespot.com/company/zepol-labs
https://www.amazon.com/dp/B019QONBV0
17个产品review里,好几个都是March 7, 2016前后留的(但不是Verified Purchase)
是不是可以顺便报告亚麻 Fake review的情况?
buyer名字极似是假名,last name 正好是公司名字的逆序,估计全世界也独一无二吧
??
TNND
d********f
发帖数: 8289
23
来自主题: ebiz版 - 这个骗子有可能拿到钱吗?
https://www.amazon.com/sp?_encoding=UTF8&asin=&isAmazonFulfilled=0&isCBA=&
marketplaceID=ATVPDKIKX0DER&orderID=102-1901656-9648256&seller=
A3RPH799354JE9&tab=&vasStoreID=
G******4
发帖数: 51
24
来自主题: ebiz版 - E Distributor 你注意些。
就是这家:https://www.amazon.com/sp?_encoding=UTF8&asin=B01MDPLX5M&
isAmazonFulfilled=0&isCBA=&marketplaceID=ATVPDKIKX0DER&orderID=&seller=
A2PQIO80FPDIRG&tab=&vasStoreID=
G******4
发帖数: 51
25
https://www.amazon.com/sp?_encoding=UTF8&asin=&isAmazonFulfilled=&isCBA=&
marketplaceID=ATVPDKIKX0DER&orderID=&seller=A2EGOOMANNXJGY&tab=&vasStoreID=
就是这家店
W****F
发帖数: 8235
26
大家发现的请在这个帖子下面跟帖曝光。
有一些是不懂用beat by cents危害的,但经过大讨论或别人提醒后明白用beat by
cents危害后,已经进停用。这些人的店名和链接请大家在帖子中删除。
每个行当都要有一定的规则和秩序来维护和维持这一行当中大多数人(即大多数神医和
大多数护士)的共同利益。希望大家能共同遵守并且互相监督,一起维护和维持这些规
则和秩序。谢谢!
1. High Life
https://www.amazon.com/sp?_encoding=UTF8&asin=B077TFZ323&isAmazonFulfilled=1
&isCBA=&marketplaceID=ATVPDKIKX0DER&orderID=&seller=A3VC3ZXGXDPKSR&tab=&
vasStoreID=
p***n
发帖数: 635
27
来自主题: JobHunting版 - 一个简单的SQL查询题
两个表:
Customer
CustomerID,Name
Order
OrderID,CustomerID做FK
1 2
2 5
3 8
4 2
5 2
6 8
写个查询语句,返回数据对:
订单数 客户数目
譬如上边的表总结一下就是这样:
1 1
2 1
3 1
N*D
发帖数: 3641
28
来自主题: JobHunting版 - 发个面试题
class Customer {
String id;
State state; // assume it asks for customers who live in certain state,
not state of shipping address of an order.
Gender gender;
List orders;
}
class Order {
String orderId;
Customer customer;
List> itemQuantityPairs;
}
class Item {
String itemId;
Double unitPrice; // in $
}
S*******o
发帖数: 2
29

昨晚在网上买的电话卡,试了很多次,very annoying。不过以下是我的经验
1。 使用英文界面
2。 clean up the history of your browser by clicking tools/internet options/
3. make sure your IE is using 128 bit encryption by clicking help/about
4. 当你make payment时,记下orderid, 如果看不到密码,可以打电话:8610-88511155
x6826, or 6811, 6817 etc,查询是否你的order 成功,或者查询技术问题。打电话021-
50544510 x8638 or 8648查询密码。
5。可以在晚一些时候上网,这样server也许会有反应。
s*****l
发帖数: 2776
30
来自主题: shopping版 - Warranty Issue of Lenovo Outlet Product
把你的orderid发给kf,说明你需要更新你的保修,大概两天,就会给你改过来
y***m
发帖数: 7027
31
来自主题: shopping版 - 哪里买数码相机?
这个么,怎么用gift card? 质量不好1年内无偿包邮退货么? ms costco何时何地可以
退?
http://www.staples.com/office/supplies/yourorder?orderId=93986925&catentryId_1=320369&formAction=&ddkey=StaplesAddToCart
thx!
V********6
发帖数: 593
32
来自主题: shopping版 - 请教ptel可用smart phone, 多谢!
这个怎么样?
https://www-ssl.bestbuy.com/site/olspage.jsp?orderId=BBY01-620459042210&
orderProcessed=false&type=page&id=pcat17027
原来用的是verizon的iphone4s, 换成PTEL后,暂用一个十几刀的无数据功能的便宜手
机过渡,用的实在不方便,想再找个一般的解锁的smart phone。 现在不想换iphone5,
想等6。
c*******y
发帖数: 1630
33
来自主题: Stock版 - 用ib api的同学能进来一下么
OK, I figure it out.
solutions:
1. use orderID of the first order of the group which is unique anyway.
2. use system time
w***o
发帖数: 3830
34
来自主题: PHILADELPHIA版 - bingo
杂志名称 订阅说明 数量
女友 从2002年9月开始,到2002年12月,共4月 1
青年文摘 从2002年9月开始,到2002年12月,共4月 1
TotalPrice: US$22.40
OrderID: MGZ189845
您可以登陆您的个人帐户查询您的订阅记录
p**o
发帖数: 3409
35
来自主题: E-Sports版 - Heart of the Swarm arrives March 12, 2013
Hello,
We now have delivery date(s) for the order you placed
on March 28, 2012 (Order# **********):
"StarCraft II: Heart of the Swarm"
Estimated arrival date: March 12, 2013
If you want to check on the progress of your order,
take a look at this page in Your Account:
https://www.amazon.com/gp/css/summary/edit.html?orderID=**********
We hope to see you again soon!
Sincerely,
Customer Service Department
http://www.amazon.com
j*****2
发帖数: 457
j*****2
发帖数: 457
j*****2
发帖数: 457
C****c
发帖数: 9157
39
来自主题: PhotoGear版 - amazon的D800好像又悲剧了.....
不是我的,我还没收到..这人是Feb 06的蛋
一下子推到5月了....
amazon发出去的最晚的单现在应该在Feb 06 10:30pm~11:00pm之间
--------
Hello,
We now have delivery date(s) for the order you placed on February 06, 2012 (
Order# 105-8506XXX-435XXXX):
"Nikon D800 36.3 MP CMOS FX-Format Digital SLR Camera (Body Only)"
Estimated arrival date: May 02, 2012 - May 03, 2012
If you want to check on the progress of your order, take a look at this page
in Your Account:
https://www.amazon.com/...gp/css/summary/edit.html?orderID=105-850XXX-
435XXXX
We ho... 阅读全帖
C****c
发帖数: 9157
40
来自主题: PhotoGear版 - D800
Hello,
We now have delivery date(s) for the order you placed on February 07, 2012 (
Order# 105-3963XXX-4809XXX):
"Nikon D800 36.3 MP CMOS FX-Format Digital SLR Camera (Body Only)"
Estimated arrival date: May 08, 2012
If you want to check on the progress of your order, take a look at this page
in Your Account:
https://www.amazon.com/gp/css/summary/edit.html?orderID=105-3963XXX-4809XXX
We hope to see you again soon!
Sincerely,
Customer Service Department
http://www.amazon.com
c******e
发帖数: 545
41
宣传的再牛逼的活性炭的过滤器都是渣,家用还是得用反渗
比如这个:
http://www.amazon.com/gp/product/B003XELTTG?psc=1&redirect=true
再搞个TDS meter就齐活了:
https://www.amazon.com/gp/css/summary/edit.html/ref=dp_iou_view_this_order?
ie=UTF8&orderID=112-3007427-4488234
换芯比较频繁的就是前级的sediment filter,便宜。RO膜可以管很久
n******7
发帖数: 5678
D*******r
发帖数: 37
43
【 以下文字转载自 Database 讨论区,原文如下 】
发信人: DVDplayer (专放DVD VCD), 信区: Database
标 题: 问关于group by的问题
发信站: Unknown Space - 未名空间 (Sat Mar 5 01:16:54 2005) WWW-POST
My table has following fields:
OrderID, Customer, Price, Quantity
Then how I can get the total price by Customer for all Customers?
Thanks in advance.
D*******r
发帖数: 37
44
来自主题: Database版 - 问关于group by的问题
My table has following fields:
OrderID, Customer, Price, Quantity
Then how I can get the total price by Customer for all Customers?
Thanks in advance.
m**********2
发帖数: 2252
45
来自主题: Database版 - 请教高手,包子谢
有2个table
table1:
tablID, CustomerID, inquery code,inquerydate
34, 12345, A, 1/1/2010
35, 12346, A, 1/3/2010
36, 12345, B, 1/5/2010
37, 12346, B, 1/8/2010
38, 12345, C, 1/20/2010
39, 12346, C, 1/24/2010
......
table2:
orderID, CustomerID, orderdate
2001, 12345, 1/15/2010
2002, 12346, 1/12/2010
我现在想做个report,如下结果:
customerID, inquery code,inquerydate
12345, B
12346, B
就是说,找出的inquery code在orderdate之前的最后一次。
包子谢!
c*****d
发帖数: 6045
46
作为新手,你可以把这个简化成几个步骤
1. 写一个trigger,这个trigger能够在用户执行insert INTO ORDERITEMS (orderid,
partid, qty)的时候自动产生一个新的detail,现在可以先用max+1,以后学了
sequence可以修改
2. 上面这个trigger实现了,并测试之后写存储过程,存储过程其实就是简化了insert
语句,只要提供i_Orderid, i_partid, i_Qty
P********R
发帖数: 1691
47
谢谢!
就是这样做的,但好象trigger自动产生的新的detail不能在INSERT的时候读取。
在trigger里用了:
SELECT NVL(MAX(detail), 0) + 1
INTO v_Newdetail
FROM ORDERITEMS
WHERE orderid = v_Orderid;
:new.detail = v_Newdetail;

,
insert
P********R
发帖数: 1691
48
来自主题: Database版 - Transact SQL问题请教
IF EXISTS (SELECT name FROM SYSOBJECTS WHERE name = 'GetNewDetail')
BEGIN DROP PROCEDURE GetNewDetail; END;
GO
CREATE PROCEDURE GetNewDetail
@vOrderid SMALLINT,
@vNewDetail SMALLINT OUTPUT
AS
BEGIN
SELECT @vNewDetail = MAX(ISNULL((detail), 0)) + 1
FROM ORDERITEMS
WHERE orderid = @vOrderid;
END;
z0
发帖数: 71
49
select a.CustomerID ,
a.OrderDate ,
a.OrderID
from your_table a
join your_table b
on a.CustomerID = b.CustomerID
and a.OrderDate between b.OrderDate - 10 and b.OrderDate
group by 1,2,3
having count(1) >= 10 ;
1 (共1页)