Tagged Questions
-2
votes
0answers
102 views
Cross-product generates duplicate rows, how to unique/distinct the result?
CREATE TABLE tbl_T0(fid int, haz float);
CREATE TABLE tbl_T1(fid int, foo text);
CREATE TABLE tbl_T2(fid int, bar money);
Populate each table with some data, then create views with ROW_NUMBER():
...
4
votes
1answer
213 views
NEWID() In Joined Virtual Table Causes Unintended Cross Apply Behavior
My actual work query was an inner join, but this simple example with cross join seems to nearly always reproduce the problem.
SELECT *
FROM (
SELECT 1 UNION ALL
SELECT 2
) AA ( A )
CROSS JOIN ...
3
votes
1answer
241 views
Build a three table join with a recusive table in the middle?
I have three relevent tables: Parts, PartGroup, and MarkupGroup.
Parts is simple.
PartID artificial primary key
Part part number
PartGroupID Foreign key
sample data:
1 ...