2016-06-28 7 views
0

저는 SQL에 익숙하지 않습니다 ... 바보 같은 질문을하면 ... 제발 신경 쓰지 마세요 여기 코드를 기반으로 데이터를 실행해야하는 첫 번째 쿼리 어디 hits.transaction. transactionId IS NOT NULL여러 WHERE 문을 사용하는 하위 쿼리 ...

SELECT, FROM 및 WHERE 문이 여러 개 있습니다. 어떻게 수정해야합니까? 당신의 WHERE 절에 여러 조건을 결합 AND/OR 키워드를 사용하려는 경우

SELECT 

date,fullvisitorid AS Users, 
hits.product.v2ProductName AS Product_Name, 
(hits.product.productPrice/1000000) AS Product_Price, 
(hits.product.productQuantity) AS Product_Quantity, 
(hits.product.productrevenue/1000000) AS Product_Revenue 

FROM ([DATASET]) 

WHERE hits.transaction.transactionId IS NOT NULL 

------------------------------------------------------------------- 
SELECT 
hits.eCommerceAction.action_type AS Product_Viewed 

FROM ([DATASET]) 

WHERE hits.eCommerceAction.action_type = '2' 
+2

달성하고자하는 목표는 무엇입니까? 테이블 데이터와 예상 출력을 예제로 제공 할 수 있습니까? –

+0

첫 번째 SELECT는 5 개의 열을 반환하고 SECOND는 하나의 열만 반환합니다. 어떻게 결과 집합을 "결합"하시겠습니까? – jarlh

+0

날짜, 사용자, Product_Name, Product_Price, Product_Quantity, Product_Revenue -이 모든 열은 하나의 테이블에서 사용할 수 있으며이 모든 항목을 하나의 비주얼로 표시하여 총 제품 수를 표시 할 수 있습니다. 총 제품 수익 대 총 제품 수 Product_Viewed는 '2'로 조건을 가져올 수 있으며 나머지는 모두 가져와야합니다. hits.transaction.transactionId가 NULL이 아니면 .... 또는이 모든 열은 NULL 값을 가진 데이터를 가져옵니다. –

답변

0

당신은

SELECT 
date,fullvisitorid AS Users, 
hits.product.v2ProductName AS Product_Name, 
(hits.product.productPrice/1000000) AS Product_Price, 
(hits.product.productQuantity) AS Product_Quantity, 
(hits.product.productrevenue/1000000) AS Product_Revenue, 
hits.eCommerceAction.action_type AS Product_Viewed 
from ([DATASET]) 
WHERE hits.transaction.transactionId IS NOT NULL 
AND 
hits.eCommerceAction.action_type = '2' 
+0

Product_Name, Product_Price, Product_Quantity 및 Product_Revenue 열은 조건 hits.transaction.transactionId의 기준을 반영해야합니다. IS NOT NULL이고 Product_Viewed는 hits.eCommerceAction.action_type = '2'....에 기초를 반영해야합니다. 예 다른 열에 대한 두 조건이 있습니다 –

0

처럼이 결합 할 수 있습니다.

SELECT 

date,fullvisitorid AS Users, 
hits.product.v2ProductName AS Product_Name, 
(hits.product.productPrice/1000000) AS Product_Price, 
(hits.product.productQuantity) AS Product_Quantity, 
(hits.product.productrevenue/1000000) AS Product_Revenue, 
hits.eCommerceAction.action_type AS Product_Viewed 

FROM ([DATASET]) 

WHERE hits.transaction.transactionId IS NOT NULL 
AND 
hits.eCommerceAction.action_type = '2' 
+0

Product_Name, Product_Price, Product_Quantity 및 Product_Revenue 열은 조건 hits.transaction.transactionId의 기준을 반영해야합니다. IS NOT NULL이고 Product_Viewed는 hits.eCommerceAction.action_type = '2' –

+0

의 기초를 반영해야합니다. 'hits.transaction.transactionId IS NOT NULL'을 의미해야합니다. 언급 한 열에 만 적용 할 수 있습니까? – MusicLovingIndianGirl

+0

Product_Name, Product_Price, Product_Quantity 및 Product_Revenue 열은 조건 hits.transaction.transactionId의 기준을 반영해야합니다. IS NOT NULL이고 Product_Viewed는 hits.eCommerceAction.action_type = '2'....에 기초를 반영해야합니다. 예 다른 열에 대한 두 조건이 있습니다. –