1. 程式人生 > 其它 >SQL server進階查詢

SQL server進階查詢

這些是一些函式使用方法

   先來張表

然後程式碼如下:

create table tb_inoutfield
(
xid float,
xname nvarchar(255),
xtype nvarchar(255)
);

INSERT INTO tb_inoutfield (xid, xname, xtype) VALUES (1, N'工資', N'收入');
INSERT INTO tb_inoutfield (xid, xname, xtype) VALUES (2, N'獎金', N'收入');
INSERT INTO tb_inoutfield (xid, xname, xtype) VALUES (3, N'分紅', N'收入');
INSERT INTO tb_inoutfield (xid, xname, xtype) VALUES (4, N'送禮', N'支出');
INSERT INTO tb_inoutfield (xid, xname, xtype) VALUES (5, N'坐車', N'支出');
INSERT INTO tb_inoutfield (xid, xname, xtype) VALUES (6, N'伙食', N'支出');
INSERT INTO tb_inoutfield (xid, xname, xtype) VALUES (7, N'電話費', N'支出');

INSERT INTO tb_inoutfield (xid, xname, xtype) VALUES (9, N'穿衣', N'支出');
INSERT INTO tb_inoutfield (xid, xname, xtype) VALUES (10, N'旅遊', N'支出');

--查詢收支專案表
select * from Tb_InOutField

如下圖所展示

查詢所有梁姓家庭成員
select * from Tb_Users where left(uname,1)='樑'

如下圖所示