On 17 November 2010 22:13, Jeff Archer <[email protected]> wrote:
> First let me say thank you to all for the very good support that receive here.
>
> I have the these tables and view
>
.
.
.
>
> I would like to add these calculated columns to my view but not sure how to
> make
> this work.
>
> Patterns.wMicrons * nTilesX AS wTotalMicrons,
> Patterns.hMicrons * nTilesY AS hTotalMicrons,
> Patterns.wPixels * nTilesX AS wTotalPixels,
> Patterns.hPixels * nTilesY AS hTotalPixels,
>
> i.e.
> // vwPatterns
> CREATE VIEW IF NOT EXISTS [vwPatterns] AS
> SELECT Patterns.Name AS Pattern,
> Patterns.Origin_X,
> Patterns.Origin_Y,
> Patterns.wMicrons,
> Patterns.hMicrons,
> COUNT(DISTINCT Offset_X) AS nTilesX,
> COUNT(DISTINCT Offset_Y) AS nTilesY,
> Patterns.wPixels,
> Patterns.hPixels,
> Patterns.wMicrons * nTilesX AS wTotalMicrons,
> Patterns.hMicrons * nTilesY AS hTotalMicrons,
> Patterns.wPixels * nTilesX AS wTotalPixels,
> Patterns.hPixels * nTilesY AS hTotalPixels,
> Patterns.Description
> FROM Tiles INNER JOIN Patterns ON Tiles.PatternID = Patterns.PatternID
> GROUP BY Tiles.PatternID;
>
> But it get error: "no such column: nTilesX"
CREATE VIEW IF NOT EXISTS [vwPatterns] AS
SELECT Patterns.Name AS Pattern,
Patterns.Origin_X,
Patterns.Origin_Y,
Patterns.wMicrons,
Patterns.hMicrons,
COUNT(DISTINCT Offset_X) AS nTilesX,
COUNT(DISTINCT Offset_Y) AS nTilesY,
Patterns.wPixels,
Patterns.hPixels,
Patterns.wMicrons * COUNT(DISTINCT Offset_X) AS wTotalMicrons,
Patterns.hMicrons * COUNT(DISTINCT Offset_Y) AS hTotalMicrons,
Patterns.wPixels * COUNT(DISTINCT Offset_X) AS wTotalPixels,
Patterns.hPixels * COUNT(DISTINCT Offset_Y) AS hTotalPixels,
Patterns.Description
FROM Tiles INNER JOIN Patterns ON Tiles.PatternID = Patterns.PatternID
GROUP BY Tiles.PatternID;
>
> It works if I substitute a constant for the nTilesX and nTilesY so I think I
> do
> not know how to correctly reference these.
>
> Thank you.
>
> Jeff Archer
> Nanotronics Imaging
> [email protected]
> <330>819.4615
Regards,
Simon
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users