SELECT COUNT(*) FROM COMPETITION


DROP VIEW VW_PRUEBA
GO
CREATE VIEW VW_PRUEBA     
AS

SELECT I.INVTIDSKU,I.DESCR,C.COMPETITIONID,C.SLS_PRICE
FROM IN_INVENTORY AS I LEFT JOIN IN_COMPETITIONPRICEDET AS C
ON I.INVTIDSKU=C.INVTIDSKU
WHERE I.CLASSID=(SELECT CATEGORYFUEL FROM OP_SETUP)



SELECT * FROM IN_INVENTORYDES 


SELECT SUM(QTY) AS CANTIDAD,INVTIDSKU,DOCTYPEID 
FROM OP_SALESDET
GROUP BY INVTIDSKU,DOCTYPEID
GO
SELECT SUM(QTY) AS CANTIDAD,INVTIDSKU,DOCTYPEID 
FROM OP_SALESDET
GROUP BY INVTIDSKU,DOCTYPEID WITH CUBE

GO
SELECT * FROM OP_SALESDET



DROP VIEW CUBITO

GO
CREATE VIEW CUBITO
AS
SELECT SUM(QTY) AS CANTIDAD,
CASE WHEN (GROUPING(INVTIDSKU)=1) THEN 'TODOS'
ELSE ISNULL(INVTIDSKU,'????') END AS INVTIDSKU,
CASE WHEN (GROUPING(DOCTYPEID)=1) THEN 'TODOS'
ELSE ISNULL(DOCTYPEID,'????') END AS DOCTYPEID
FROM OP_SALESDET
GROUP BY INVTIDSKU,DOCTYPEID WITH CUBE

SELECT * FROM CUBITO

SELECT  SUM(QTY) AS CANTIDAD FROM OP_SALESDET




