The Custom Export using SQL is the feature that executes SQL command to a CSV file, it is also where SQL commands are saved and opened as .sql files. The SQL command is written in Cube-IQ's Export (User Definable) dialog window.
Open the Export (User Definable) dialog window by: 1) click the main menu, 2) click Import & Export tab in the left panel, 3) click the Custom Export using SQL button
The top part of the Export (User Definable) dialog window is where the buttons are to open and save .sql files for the Export command, the middle area is where the SQL command is written, and the lower part of the dialog window is where the Export is saved and the command is executed.
Cube-IQ SQL Tables, Fields, and Commands
Cube-IQ uses standard SQL commands and syntax such as SELECT, SUM, JOIN, GROUP BY, and ORDER BY… etc.
There are plenty of Tables and Fields in Cube-IQ. Here are some common tables used: Loads, Products, Containers, ProductsToLoad, and Blocks
Naming of fields normally follow the convention where key fields of a table are <table name> + "id". For example, the key field for Loads, Products and Containers are LoadId, ProductId, and ContainerId. The other field names are normally their name used throughout Cube-IQ such as Length, Width, Height, Quantity, TopOnly, MaxInLayer… etc.
The Custom Export using SQL feature can reference the current Load open by using this macro substitution: '%LoadId%'
Example of a Custom CSV Export for a "Products Not Loaded.csv" report
Here is the Sample Load in Cube-IQ where there are 6 Products Not Loaded.
This SQL export command will list the LoadId, ProductId, Quantity, Loaded, and Not Loaded from the current open Load.
Note how the '%loadid%' bolded in red is the macro substitution used to reference the currently open Load.
SELECT ProductsToLoad.LoadId, ProductsToLoad.ProductId, ProductsToLoad.Quantity,
SUM(Blocks.NumDeep*Blocks.NumWide*Blocks.NumHigh) AS Loaded,
ProductsToLoad.Quantity-SUM(Blocks.NumDeep*Blocks.NumWide*Blocks.NumHigh) AS Not_Loaded
FROM ProductsToLoad
LEFT JOIN Blocks ON ProductsToLoad.ProductId=Blocks.ProductId AND ProductsToLoad.LoadId=Blocks.LoadId
WHERE ProductsToLoad.LoadId = '%loadid%'
GROUP BY Blocks.ProductId, Blocks.ContainerSeqNo
ORDER BY Blocks.ProductId, Blocks.ContainerSeqNo
Place the command above into the Export (User Definable) dialog window, and then click export after entering the path and filename in the Filename field.