我正在尝试从列中选择不同的值,但返回与所选值相关的所有行。在伪代码中,它看起来像这样。
SELECT *
FROM table
WHERE field is Distinct
我用谷歌搜索了这个问题,我试过使用 GROUP BY 但查询永远不会执行。谢谢您的帮助。
我正在使用 Microsoft SQL 数据库。
数据如下所示:
CodeId Code CatalogType CodeGroup CodeText CodeGroupText CodeDesc State_ID
------- ----- ------------- ---------- -------- -------------- --------- ---------
1 AAAA 1 100 Plastic Plastic Center NULL 2
2 BBBB 1 100 Glass Glass Center NULL 2
3 CCCC 1 101 Steel Steel Center NULL 2
我只想让数据在代码组不同的地方看起来相同。
数据如下所示:
CodeId Code CatalogType CodeGroup CodeText CodeGroupText CodeDesc State_ID
------- ----- ------------- ---------- -------- -------------- --------- ---------
1 AAAA 1 100 Plastic Plastic Center NULL 2
3 CCCC 1 101 Steel Steel Center NULL 2