我正在创建一个视图,其中几乎复制了原始用户的数据,但我还有一个属性,我想将用户在下载表中的出现次数放在其中。
CREATE VIEW customer_count_streams_vw(
sid_customer
systemuser_id
postcode
age
gender
num_streams)
AS
SELECT
user.sid_customer,
user.systemuser_id,
user.postcode,
user.age,
user.gender,
num_streams
FROM md_customer
INNER JOIN ods_streaming AS num_streams (
SELECT COUNT(ods_streaming.sid_customer)
WHERE ods_streaming.sid_customer = md_customer.sid_customer)
我想要的是放置零件的结果:
SELECT COUNT(ods_streaming.sid_customer)
WHERE ods_streaming.sid_customer = md_customer.sid_customer
进入num_streams
领域。