干得好。
创建代码:
/****** Object: Table [dbo].[Blok] Script Date: 11.11.2015 10:46:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Blok](
[blok_id] [int] IDENTITY(1,1) NOT NULL,
[blok_l_id] [int] NULL,
[blok_isim] [nvarchar](50) NULL,
CONSTRAINT [PK_Blok] PRIMARY KEY CLUSTERED
(
[blok_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[DaireGecmis] Script Date: 11.11.2015 10:46:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DaireGecmis](
[dg_id] [int] IDENTITY(1,1) NOT NULL,
[dg_d_id] [int] NULL,
[dg_p_id] [int] NULL,
[dg_islemtarihi] [datetime] NULL,
[dg_islem] [nvarchar](50) NULL,
[dg_giristarihi] [date] NULL,
[dg_cikistarihi] [date] NULL,
[dg_karartarihi] [date] NULL,
[dg_feragattarihi] [date] NULL,
[dg_tahsisturu] [nvarchar](50) NULL,
[dg_aciklama] [nvarchar](50) NULL,
[dg_kesintiyazildimi] [bit] NULL,
[dg_kararid] [int] NULL,
[dg_yonetimeyazildimi] [int] NULL,
CONSTRAINT [PK_DaireGecmis] PRIMARY KEY CLUSTERED
(
[dg_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Daireler] Script Date: 11.11.2015 10:46:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Daireler](
[d_id] [int] IDENTITY(1,1) NOT NULL,
[d_kod] [int] NULL,
[d_il] [nvarchar](50) NULL,
[d_ilce] [nvarchar](50) NULL,
[d_semt] [nvarchar](50) NULL,
[d_mahalle] [nvarchar](50) NULL,
[d_aciklama] [varchar](500) NULL,
[d_cadde] [nvarchar](50) NULL,
[d_sokak] [nvarchar](50) NULL,
[d_blok] [nvarchar](50) NULL,
[d_apartman] [nvarchar](50) NULL,
[d_no] [nvarchar](50) NULL,
[d_metrekare] [int] NULL,
[d_oda] [nvarchar](50) NULL,
[d_giriskat] [bit] NULL,
[d_ustkat] [bit] NULL,
[d_l_id] [int] NULL,
[d_blok_id] [int] NULL,
[d_p_id] [int] NULL,
CONSTRAINT [PK_Daireler1] PRIMARY KEY CLUSTERED
(
[d_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[Lojmanlar] Script Date: 11.11.2015 10:46:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Lojmanlar](
[l_id] [int] IDENTITY(1,1) NOT NULL,
[l_isim] [nvarchar](50) NULL,
[l_turu] [nvarchar](50) NULL,
CONSTRAINT [PK_Lojmanlar] PRIMARY KEY CLUSTERED
(
[l_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Personel] Script Date: 11.11.2015 10:46:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Personel](
[p_id] [int] IDENTITY(1,1) NOT NULL,
[p_tc] [nvarchar](11) NULL,
[p_adsoyad] [nvarchar](50) NULL,
[p_kurumsicil] [int] NULL,
[p_gorevunvani] [nvarchar](100) NULL,
[p_gorevyeri] [nvarchar](100) NULL,
[p_istel] [varchar](50) NULL,
[p_ceptel] [varchar](50) NULL,
[p_hizmetyil] [int] NULL,
[p_hizmetay] [int] NULL,
[p_hizmetgun] [int] NULL,
[p_oncekilojmanyil] [int] NULL,
[p_oncekilojmanay] [int] NULL,
[p_oncekilojmangun] [int] NULL,
[p_ankaraiciev] [int] NULL,
[p_ildisiev] [int] NULL,
[p_disiplincezasi] [bit] NULL,
[p_medenihal] [bit] NULL,
[p_cocuksayisi] [int] NULL,
[p_annebaba] [int] NULL,
[p_esininmeslegi] [nvarchar](50) NULL,
[p_esyillikgelir] [int] NULL,
[p_hakimsavci] [bit] NULL,
[p_puan] [int] NULL,
[p_d_id] [int] NULL,
[p_mazeret] [nvarchar](100) NULL,
[p_sira] [int] NULL,
[p_feragat] [bit] NULL,
[p_giriskat] [bit] NULL,
[p_ustkat] [bit] NULL,
[p_vpuan] [int] NULL,
[p_evadresi] [varchar](50) NULL,
CONSTRAINT [PK_personel] PRIMARY KEY CLUSTERED
(
[p_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET IDENTITY_INSERT [dbo].[Blok] ON
GO
INSERT [dbo].[Blok] ([blok_id], [blok_l_id], [blok_isim]) VALUES (56, 22, N'A/3')
GO
INSERT [dbo].[Blok] ([blok_id], [blok_l_id], [blok_isim]) VALUES (61, 22, N'A/12')
GO
INSERT [dbo].[Blok] ([blok_id], [blok_l_id], [blok_isim]) VALUES (70, 27, N'C/1')
GO
INSERT [dbo].[Blok] ([blok_id], [blok_l_id], [blok_isim]) VALUES (1072, 1028, N'C/12 BLOK')
GO
SET IDENTITY_INSERT [dbo].[Blok] OFF
GO
SET IDENTITY_INSERT [dbo].[DaireGecmis] ON
GO
INSERT [dbo].[DaireGecmis] ([dg_id], [dg_d_id], [dg_p_id], [dg_islemtarihi], [dg_islem], [dg_giristarihi], [dg_cikistarihi], [dg_karartarihi], [dg_feragattarihi], [dg_tahsisturu], [dg_aciklama], [dg_kesintiyazildimi], [dg_kararid], [dg_yonetimeyazildimi]) VALUES (1003, 1384, 2699, CAST(0x0000A53800E4AFEC AS DateTime), N'Tahliye Edildi', CAST(0x802F0B00 AS Date), CAST(0x4B3A0B00 AS Date), CAST(0x6E390B00 AS Date), NULL, NULL, N'', 1, 1, 2)
GO
INSERT [dbo].[DaireGecmis] ([dg_id], [dg_d_id], [dg_p_id], [dg_islemtarihi], [dg_islem], [dg_giristarihi], [dg_cikistarihi], [dg_karartarihi], [dg_feragattarihi], [dg_tahsisturu], [dg_aciklama], [dg_kesintiyazildimi], [dg_kararid], [dg_yonetimeyazildimi]) VALUES (1026, 1397, 1987, CAST(0x0000A54400E5BF2D AS DateTime), N'Tahliye Edildi', CAST(0xBC350B00 AS Date), CAST(0x993A0B00 AS Date), CAST(0x6E390B00 AS Date), NULL, NULL, N'', 1, 1, 2)
GO
INSERT [dbo].[DaireGecmis] ([dg_id], [dg_d_id], [dg_p_id], [dg_islemtarihi], [dg_islem], [dg_giristarihi], [dg_cikistarihi], [dg_karartarihi], [dg_feragattarihi], [dg_tahsisturu], [dg_aciklama], [dg_kesintiyazildimi], [dg_kararid], [dg_yonetimeyazildimi]) VALUES (1432, 1298, 2217, CAST(0x0000A53800E3AF34 AS DateTime), N'Tahliye Edildi', CAST(0xAD200B00 AS Date), CAST(0x9D390B00 AS Date), CAST(0x6E390B00 AS Date), NULL, NULL, N'', 1, 1, 2)
GO
INSERT [dbo].[DaireGecmis] ([dg_id], [dg_d_id], [dg_p_id], [dg_islemtarihi], [dg_islem], [dg_giristarihi], [dg_cikistarihi], [dg_karartarihi], [dg_feragattarihi], [dg_tahsisturu], [dg_aciklama], [dg_kesintiyazildimi], [dg_kararid], [dg_yonetimeyazildimi]) VALUES (1435, 1300, 2221, CAST(0x0000A53800E3FA15 AS DateTime), N'Tahliye Edildi', CAST(0xF5330B00 AS Date), CAST(0x723A0B00 AS Date), CAST(0x6E390B00 AS Date), NULL, NULL, N'', 1, 1, 2)
GO
INSERT [dbo].[DaireGecmis] ([dg_id], [dg_d_id], [dg_p_id], [dg_islemtarihi], [dg_islem], [dg_giristarihi], [dg_cikistarihi], [dg_karartarihi], [dg_feragattarihi], [dg_tahsisturu], [dg_aciklama], [dg_kesintiyazildimi], [dg_kararid], [dg_yonetimeyazildimi]) VALUES (1486, 1550, 2470, CAST(0x0000A53800E61215 AS DateTime), N'Tahliye Edildi', CAST(0x971C0B00 AS Date), CAST(0x673A0B00 AS Date), CAST(0x6E390B00 AS Date), NULL, NULL, N'', 1, 1, 2)
GO
INSERT [dbo].[DaireGecmis] ([dg_id], [dg_d_id], [dg_p_id], [dg_islemtarihi], [dg_islem], [dg_giristarihi], [dg_cikistarihi], [dg_karartarihi], [dg_feragattarihi], [dg_tahsisturu], [dg_aciklama], [dg_kesintiyazildimi], [dg_kararid], [dg_yonetimeyazildimi]) VALUES (2881, 2658, 2601, CAST(0x0000A538007B3873 AS DateTime), N'Tahliye Edildi', CAST(0xDD320B00 AS Date), CAST(0x5D3A0B00 AS Date), CAST(0x6E390B00 AS Date), NULL, NULL, N'', 1, 1, 2)
GO
INSERT [dbo].[DaireGecmis] ([dg_id], [dg_d_id], [dg_p_id], [dg_islemtarihi], [dg_islem], [dg_giristarihi], [dg_cikistarihi], [dg_karartarihi], [dg_feragattarihi], [dg_tahsisturu], [dg_aciklama], [dg_kesintiyazildimi], [dg_kararid], [dg_yonetimeyazildimi]) VALUES (2886, 2687, 2160, CAST(0x0000A5380080E315 AS DateTime), N'Tahliye Edildi', CAST(0x35320B00 AS Date), CAST(0xB8390B00 AS Date), CAST(0x6E390B00 AS Date), NULL, NULL, N'', 1, 1, 2)
GO
INSERT [dbo].[DaireGecmis] ([dg_id], [dg_d_id], [dg_p_id], [dg_islemtarihi], [dg_islem], [dg_giristarihi], [dg_cikistarihi], [dg_karartarihi], [dg_feragattarihi], [dg_tahsisturu], [dg_aciklama], [dg_kesintiyazildimi], [dg_kararid], [dg_yonetimeyazildimi]) VALUES (4918, 2687, 5813, CAST(0x0000A54600D5BDC4 AS DateTime), N'Feragat Etti', NULL, NULL, CAST(0x6E390B00 AS Date), CAST(0xA13A0B00 AS Date), NULL, N'', 0, 1, 0)
GO
INSERT [dbo].[DaireGecmis] ([dg_id], [dg_d_id], [dg_p_id], [dg_islemtarihi], [dg_islem], [dg_giristarihi], [dg_cikistarihi], [dg_karartarihi], [dg_feragattarihi], [dg_tahsisturu], [dg_aciklama], [dg_kesintiyazildimi], [dg_kararid], [dg_yonetimeyazildimi]) VALUES (4930, 1414, 5825, CAST(0x0000A546009AA675 AS DateTime), N'Feragat Etti', NULL, NULL, CAST(0x6E390B00 AS Date), CAST(0x933A0B00 AS Date), NULL, N'', 0, 1, 0)
GO
INSERT [dbo].[DaireGecmis] ([dg_id], [dg_d_id], [dg_p_id], [dg_islemtarihi], [dg_islem], [dg_giristarihi], [dg_cikistarihi], [dg_karartarihi], [dg_feragattarihi], [dg_tahsisturu], [dg_aciklama], [dg_kesintiyazildimi], [dg_kararid], [dg_yonetimeyazildimi]) VALUES (4938, 1384, 2567, CAST(0x0000A54C014A502F AS DateTime), N'Feragat Etti', NULL, NULL, CAST(0x933A0B00 AS Date), CAST(0xA73A0B00 AS Date), NULL, N'', 0, 2, 0)
GO
SET IDENTITY_INSERT [dbo].[DaireGecmis] OFF
GO
SET IDENTITY_INSERT [dbo].[Daireler] ON
GO
INSERT [dbo].[Daireler] ([d_id], [d_kod], [d_il], [d_ilce], [d_semt], [d_mahalle], [d_aciklama], [d_cadde], [d_sokak], [d_blok], [d_apartman], [d_no], [d_metrekare], [d_oda], [d_giriskat], [d_ustkat], [d_l_id], [d_blok_id], [d_p_id]) VALUES (1298, 0, N'', N'', N'', N'ATAKENT ', N'', N'', N'', N'', N'', N'31', 130, N'3', 0, 1, 22, 56, NULL)
GO
INSERT [dbo].[Daireler] ([d_id], [d_kod], [d_il], [d_ilce], [d_semt], [d_mahalle], [d_aciklama], [d_cadde], [d_sokak], [d_blok], [d_apartman], [d_no], [d_metrekare], [d_oda], [d_giriskat], [d_ustkat], [d_l_id], [d_blok_id], [d_p_id]) VALUES (1384, 0, N'', N'', N'', N'', N'', N'', N'', N'', N'', N'8', 130, N'3', 0, 0, 22, 61, NULL)
GO
INSERT [dbo].[Daireler] ([d_id], [d_kod], [d_il], [d_ilce], [d_semt], [d_mahalle], [d_aciklama], [d_cadde], [d_sokak], [d_blok], [d_apartman], [d_no], [d_metrekare], [d_oda], [d_giriskat], [d_ustkat], [d_l_id], [d_blok_id], [d_p_id]) VALUES (1397, 0, N'', N'', N'', N'', N'', N'', N'', N'', N'', N'20', 130, N'3', 0, 0, 22, 61, NULL)
GO
INSERT [dbo].[Daireler] ([d_id], [d_kod], [d_il], [d_ilce], [d_semt], [d_mahalle], [d_aciklama], [d_cadde], [d_sokak], [d_blok], [d_apartman], [d_no], [d_metrekare], [d_oda], [d_giriskat], [d_ustkat], [d_l_id], [d_blok_id], [d_p_id]) VALUES (1414, 0, N'', N'', N'', N'', N'', N'', N'', N'', N'', N'37', 130, N'3', 0, 0, 22, 61, NULL)
GO
INSERT [dbo].[Daireler] ([d_id], [d_kod], [d_il], [d_ilce], [d_semt], [d_mahalle], [d_aciklama], [d_cadde], [d_sokak], [d_blok], [d_apartman], [d_no], [d_metrekare], [d_oda], [d_giriskat], [d_ustkat], [d_l_id], [d_blok_id], [d_p_id]) VALUES (1550, 0, N'', N'', N'', N'', N'', N'', N'', N'', N'', N'23', 102, N'3', 0, 0, 27, 70, NULL)
GO
INSERT [dbo].[Daireler] ([d_id], [d_kod], [d_il], [d_ilce], [d_semt], [d_mahalle], [d_aciklama], [d_cadde], [d_sokak], [d_blok], [d_apartman], [d_no], [d_metrekare], [d_oda], [d_giriskat], [d_ustkat], [d_l_id], [d_blok_id], [d_p_id]) VALUES (2658, 0, N'', N'', N'', N'', N'', N'', N'', N'', N'', N'10', 112, N'3', 0, 0, 1028, 1072, NULL)
GO
INSERT [dbo].[Daireler] ([d_id], [d_kod], [d_il], [d_ilce], [d_semt], [d_mahalle], [d_aciklama], [d_cadde], [d_sokak], [d_blok], [d_apartman], [d_no], [d_metrekare], [d_oda], [d_giriskat], [d_ustkat], [d_l_id], [d_blok_id], [d_p_id]) VALUES (2687, 0, N'', N'', N'', N'', N'', N'', N'', N'', N'', N'39', 112, N'3', 0, 0, 1028, 1072, NULL)
GO
SET IDENTITY_INSERT [dbo].[Daireler] OFF
GO
SET IDENTITY_INSERT [dbo].[Lojmanlar] ON
GO
INSERT [dbo].[Lojmanlar] ([l_id], [l_isim], [l_turu]) VALUES (22, N'ELVANKENT', N'Vakıf')
GO
INSERT [dbo].[Lojmanlar] ([l_id], [l_isim], [l_turu]) VALUES (27, N'KONUTKENT', N'Vakıf')
GO
INSERT [dbo].[Lojmanlar] ([l_id], [l_isim], [l_turu]) VALUES (1028, N'URANKENT', N'Vakıf')
GO
SET IDENTITY_INSERT [dbo].[Lojmanlar] OFF
GO
SET IDENTITY_INSERT [dbo].[Personel] ON
GO
INSERT [dbo].[Personel] ([p_id], [p_tc], [p_adsoyad], [p_kurumsicil], [p_gorevunvani], [p_gorevyeri], [p_istel], [p_ceptel], [p_hizmetyil], [p_hizmetay], [p_hizmetgun], [p_oncekilojmanyil], [p_oncekilojmanay], [p_oncekilojmangun], [p_ankaraiciev], [p_ildisiev], [p_disiplincezasi], [p_medenihal], [p_cocuksayisi], [p_annebaba], [p_esininmeslegi], [p_esyillikgelir], [p_hakimsavci], [p_puan], [p_d_id], [p_mazeret], [p_sira], [p_feragat], [p_giriskat], [p_ustkat], [p_vpuan], [p_evadresi]) VALUES (1987, N'13238255210', N'BAYRAM SALEN', 42128, N'ÇİFTÇİ', N'ANKARA', N'( ) -', N'(505) 542-4317', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, N'', 8, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Personel] ([p_id], [p_tc], [p_adsoyad], [p_kurumsicil], [p_gorevunvani], [p_gorevyeri], [p_istel], [p_ceptel], [p_hizmetyil], [p_hizmetay], [p_hizmetgun], [p_oncekilojmanyil], [p_oncekilojmanay], [p_oncekilojmangun], [p_ankaraiciev], [p_ildisiev], [p_disiplincezasi], [p_medenihal], [p_cocuksayisi], [p_annebaba], [p_esininmeslegi], [p_esyillikgelir], [p_hakimsavci], [p_puan], [p_d_id], [p_mazeret], [p_sira], [p_feragat], [p_giriskat], [p_ustkat], [p_vpuan], [p_evadresi]) VALUES (2160, N'36736723608', N'ATILLA TAYDAC', 35736, N'BAKKAL', N'İSTANBUL', N'( ) -', N'(542) 575-2071', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, N'', 8, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Personel] ([p_id], [p_tc], [p_adsoyad], [p_kurumsicil], [p_gorevunvani], [p_gorevyeri], [p_istel], [p_ceptel], [p_hizmetyil], [p_hizmetay], [p_hizmetgun], [p_oncekilojmanyil], [p_oncekilojmanay], [p_oncekilojmangun], [p_ankaraiciev], [p_ildisiev], [p_disiplincezasi], [p_medenihal], [p_cocuksayisi], [p_annebaba], [p_esininmeslegi], [p_esyillikgelir], [p_hakimsavci], [p_puan], [p_d_id], [p_mazeret], [p_sira], [p_feragat], [p_giriskat], [p_ustkat], [p_vpuan], [p_evadresi]) VALUES (2217, N'22236137600', N'YAKUZ KEKTEN', 32486, N'BERBER', N'ÇORUM', N'( ) -', N'(050) 536-7325', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, N'', 8, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Personel] ([p_id], [p_tc], [p_adsoyad], [p_kurumsicil], [p_gorevunvani], [p_gorevyeri], [p_istel], [p_ceptel], [p_hizmetyil], [p_hizmetay], [p_hizmetgun], [p_oncekilojmanyil], [p_oncekilojmanay], [p_oncekilojmangun], [p_ankaraiciev], [p_ildisiev], [p_disiplincezasi], [p_medenihal], [p_cocuksayisi], [p_annebaba], [p_esininmeslegi], [p_esyillikgelir], [p_hakimsavci], [p_puan], [p_d_id], [p_mazeret], [p_sira], [p_feragat], [p_giriskat], [p_ustkat], [p_vpuan], [p_evadresi]) VALUES (2470, N'45512304590', N'KACUR DOGAN', 21909, N'KASAP', N'KIRŞEHİR', N'( ) -', N'(312) 416-1823', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, N'', 8, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Personel] ([p_id], [p_tc], [p_adsoyad], [p_kurumsicil], [p_gorevunvani], [p_gorevyeri], [p_istel], [p_ceptel], [p_hizmetyil], [p_hizmetay], [p_hizmetgun], [p_oncekilojmanyil], [p_oncekilojmanay], [p_oncekilojmangun], [p_ankaraiciev], [p_ildisiev], [p_disiplincezasi], [p_medenihal], [p_cocuksayisi], [p_annebaba], [p_esininmeslegi], [p_esyillikgelir], [p_hakimsavci], [p_puan], [p_d_id], [p_mazeret], [p_sira], [p_feragat], [p_giriskat], [p_ustkat], [p_vpuan], [p_evadresi]) VALUES (2567, N'19238379708', N'FATIH KOSEKACA', 105281, N'MANAV', N'ÇANKIRI', N'( ) -', N'(507) 062-4336', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, N'', 8, 0, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Personel] ([p_id], [p_tc], [p_adsoyad], [p_kurumsicil], [p_gorevunvani], [p_gorevyeri], [p_istel], [p_ceptel], [p_hizmetyil], [p_hizmetay], [p_hizmetgun], [p_oncekilojmanyil], [p_oncekilojmanay], [p_oncekilojmangun], [p_ankaraiciev], [p_ildisiev], [p_disiplincezasi], [p_medenihal], [p_cocuksayisi], [p_annebaba], [p_esininmeslegi], [p_esyillikgelir], [p_hakimsavci], [p_puan], [p_d_id], [p_mazeret], [p_sira], [p_feragat], [p_giriskat], [p_ustkat], [p_vpuan], [p_evadresi]) VALUES (2601, N'29926623496', N'AYE SOY', 400214, N'MARANGOZ', N'BALIKESİR', N'( ) -', N'(530) 540-6921', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, N'', 8, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Personel] ([p_id], [p_tc], [p_adsoyad], [p_kurumsicil], [p_gorevunvani], [p_gorevyeri], [p_istel], [p_ceptel], [p_hizmetyil], [p_hizmetay], [p_hizmetgun], [p_oncekilojmanyil], [p_oncekilojmanay], [p_oncekilojmangun], [p_ankaraiciev], [p_ildisiev], [p_disiplincezasi], [p_medenihal], [p_cocuksayisi], [p_annebaba], [p_esininmeslegi], [p_esyillikgelir], [p_hakimsavci], [p_puan], [p_d_id], [p_mazeret], [p_sira], [p_feragat], [p_giriskat], [p_ustkat], [p_vpuan], [p_evadresi]) VALUES (2699, N'54239361302', N'DURUN AYR', 32324, N'DEMİRCİ', N'YENİŞEHİR', N'( ) -', N'(505) 488-2323', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, N'', 8, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Personel] ([p_id], [p_tc], [p_adsoyad], [p_kurumsicil], [p_gorevunvani], [p_gorevyeri], [p_istel], [p_ceptel], [p_hizmetyil], [p_hizmetay], [p_hizmetgun], [p_oncekilojmanyil], [p_oncekilojmanay], [p_oncekilojmangun], [p_ankaraiciev], [p_ildisiev], [p_disiplincezasi], [p_medenihal], [p_cocuksayisi], [p_annebaba], [p_esininmeslegi], [p_esyillikgelir], [p_hakimsavci], [p_puan], [p_d_id], [p_mazeret], [p_sira], [p_feragat], [p_giriskat], [p_ustkat], [p_vpuan], [p_evadresi]) VALUES (5813, N'40759022396', N'SELAT GCRAY', 34238, N'ELEKTRİKÇİ', N'ESKİŞEHİR', N'( ) -', N'(505) 227-2369', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, N'', 8, 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Personel] ([p_id], [p_tc], [p_adsoyad], [p_kurumsicil], [p_gorevunvani], [p_gorevyeri], [p_istel], [p_ceptel], [p_hizmetyil], [p_hizmetay], [p_hizmetgun], [p_oncekilojmanyil], [p_oncekilojmanay], [p_oncekilojmangun], [p_ankaraiciev], [p_ildisiev], [p_disiplincezasi], [p_medenihal], [p_cocuksayisi], [p_annebaba], [p_esininmeslegi], [p_esyillikgelir], [p_hakimsavci], [p_puan], [p_d_id], [p_mazeret], [p_sira], [p_feragat], [p_giriskat], [p_ustkat], [p_vpuan], [p_evadresi]) VALUES (5825, N'46582331814', N'MAT AKSAKAL', 138934, N'BOYACI', N'ŞIRNAK', N'( ) -', N'(554) 349-1226', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, N'', 8, 0, NULL, NULL, NULL, NULL)
GO
SET IDENTITY_INSERT [dbo].[Personel] OFF
GO
/****** Object: Index [MÜKERRER SİCİL GİRİŞ ENGELİ] Script Date: 11.11.2015 10:46:14 ******/
ALTER TABLE [dbo].[Personel] ADD CONSTRAINT [MÜKERRER SİCİL GİRİŞ ENGELİ] UNIQUE NONCLUSTERED
(
[p_kurumsicil] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON
GO
/****** Object: Index [MÜKERRER TC GİRİŞ ENGELİ] Script Date: 11.11.2015 10:46:14 ******/
ALTER TABLE [dbo].[Personel] ADD CONSTRAINT [MÜKERRER TC GİRİŞ ENGELİ] UNIQUE NONCLUSTERED
(
[p_tc] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
选择代码:
SELECT
Daireler.d_id, Daireler.d_l_id, Daireler.d_blok_id, Daireler.d_p_id, Daireler.d_no,
Blok.blok_id, Blok.blok_isim, Lojmanlar.l_id, Lojmanlar.l_isim, Lojmanlar.l_turu,
DaireGecmis.dg_id, DaireGecmis.dg_d_id, DaireGecmis.dg_p_id, DaireGecmis.dg_cikistarihi,
DaireGecmis.dg_feragattarihi, DaireGecmis.dg_aciklama, Personel.p_id, Personel.p_adsoyad,
Personel.p_kurumsicil, Personel.p_gorevunvani, Daireler.d_metrekare, Daireler.d_oda,
Daireler.d_giriskat, Daireler.d_ustkat, Daireler.d_aciklama
FROM
Daireler
INNER JOIN Blok ON Daireler.d_blok_id = Blok.blok_id
INNER JOIN Lojmanlar ON Daireler.d_l_id = Lojmanlar.l_id
INNER JOIN DaireGecmis ON Daireler.d_id = DaireGecmis.dg_d_id
INNER JOIN Personel ON DaireGecmis.dg_p_id = Personel.p_id
WHERE
(Daireler.d_p_id IS NULL) AND (Lojmanlar.l_turu = 'Vakıf')
ORDER BY
Lojmanlar.l_turu, Lojmanlar.l_isim, Blok.blok_isim,
CASE WHEN ISNUMERIC(Daireler.d_no) = 1 THEN 0 ELSE 1 END,
CASE WHEN ISNUMERIC(Daireler.d_no) = 1 THEN CAST(Daireler.d_no AS INT) ELSE 0 END,
Daireler.d_no
结果: Result
我的问题
多个DaireGecmis.dg_d_id
如果有DaireGecmis.dg_id
,则会带来额外的记录。
我已经标记了我不想出现黄色的地方。 image 2
感谢您的帮助。
创建者并插入我上面给出的代码数据库信息。 在系统上添加此代码后,运行我在下面提供的查询代码。 我报告了图片的结果。 2.在我用黄线描绘的图片中,我希望这个过滤器可用。
此查询将允许过滤将您发送给我?
答案 0 :(得分:0)
要删除重复的行,您可以使用ROW_NUMBER()
。您的代码如下:
SELECT * FROM
(
SELECT *,
ROW_NUMBER() OVER(PARTITION BY duplicated columns ORDER BY (SELECT NULL)) AS RN
FROM Your_Table_Result
) AS A
WHERE RN = 1
示例:我有一个名为TBR
的表结果,如:
ID C1 C2 C3
1 1 2 1
1 1 2 2
1 2 2 1
1 2 3 1
我想删除重复ID C1 C2
列并获取MAX C3
结果LIKE:
ID C1 C2 C3
1 1 2 2
1 2 2 1
1 2 3 1
我的查询:
SELECT * FROM
(
SELECT *,
ROW_NUMBER() OVER(PARTITION BY ID, C1, C2 ORDER BY C3 DESC) AS RN
FROM TBR
) AS A
WHERE RN = 1
如果我想获得MIN C3
,我ORDER BY C3
。如果我想获得top down C3
,我ORDER BY (SELECT NULL)