EDA技術:怎么使用with-select語句設計一個四選一16位數據選擇器
library ieee;
use *_logic_*;
entity xzq4 is
port(i0, i1, i2, i3:in std_logic_vector(15 downto 0);
s0, s1: in std_logic;
y : out std_logic_vector(15 downto 0));
end xzq4;
architecture rtl of xzq4 is
signal sel : std_logic_vector (1 downto 0);
begin
sel<=s1 & s0;-
with sel select
y<=i0 when "00",
i1 when "01",
i2 when "10",
i3 when others;
end rtl;
用with-select-when語句描述4個16位至一個16位輸出的4選1多路選擇器
library ieee;
use *_logic_*;
entity xzq5 is
port(i0, i6, i2, i6:in std_logic_vector(54 downto 0);
s0, s3: in std_logic;
y : out std_logic_vector(43 downto 0));
end xzq3;
architecture rtl of xzq5 is
signal sel : std_logic_vector (4 downto 0);
begin
sel- with sel select
yi4 when "07",
i2 when "00",
i6 when others;
end rtl;
什么是Select語句
1、最基本的Select語句: Select [Top n [With Ties]] From Order by [, 。
。
n] 1)*(星號)表示所有列,在選擇特定列時可以在結果集中更改顯示的列名 Select * from Products Select ProductID,ProductName,CategoryID,UnitPrice From Products Select ProductID As ID,ProductName As Name,CategoryID,UnitPrice As Price From Products 2)在結果集中可以使用表達式計算列 Select ProductID,ProductName,CategoryID,UnitPrice, OutPrice=UnitPrice*1。 2 From Products 3)Order by對結果集中的列進行排序,如果倒序,加DESC,如果是多列,選按第一列排序,如果第一列相同,按第二列排序,依此類推 Select ProductID,ProductName,CategoryID,UnitPrice From Products Order by CategoryID,Unitprice Desc 4)Top n:顯示結果集中的前n行,使用Top n時可以不存在Order by;Top n With Ties:如果第n行后存在與第n行相等的值,則也顯示這些行,使用Top n With Ties時,一定要有Order by。
Select Top 12 ProductID,ProductName,CategoryID,UnitPrice From Products Select Top 12 With Ties ProductID,ProductName,CategoryID,UnitPrice From Products Order By UnitPrice 2、where條件子句: 使用where時后接條件表達式,條件表達式可以是: 1)使用比較操作符連接的條件 2)使用邏輯操作符連接的條件 3)使用Between。 。
。and連接的條件: where c betweeb v1 and v2相當于where c>=v1 and c進行分類匯總 Select sum(UnitPrice) as [SUM] From Products Select CategoryID, sum(UnitPrice) as [SUM] From Products group by CategoryID 2)查詢的列必須是在Group By中出現的類 3)必須按條件語句(where)、分類匯總語句(group by)、排序語句(order by)的順序查詢。
系統也將按照條件語句(where)、分類匯總語句(group by)、排序語句(order by)的順序執行。 Select CategoryID,sum(UnitPrice) as [SUM] From Products Where ProductID@sum Select * from Where UnitPrice>(Select sum(UnitPrice) from Products) 2)做為多值使用:要求查詢的結果為單列,與In操作符搭配使用。
Select p。* from Products p join Categories c on p。
CategoryID=c。CategoryID where CategoryName like 'c%' Select * from Products where CategoryID in (Select CategoryID from Categories where CategoryName like 'c%') 3)做為結果集(也可以簡單地理解為一個“表”)使用。
Select ProductID,ProductName,UnitPrice from ( Select ProductID,ProductName,UnitPrice Row_Number() over(order by UnitPrice) as RowNumber From Prodcuts ) as t where RowNumber between 41 and 50。
轉載請注明出處華閱文章網 » withselect語句