Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Table one
==========
SQL
CREATE TABLE [mst].[Car](
    [CarId] [int] IDENTITY(1,1) NOT NULL,
    [BrandId] [int] NULL,
    [ModelId] [int] NULL,
    [IsAction] [bit] NOT NULL,   
    [VarientId] [int] NULL,
    [DealerId] [int] NULL,
    [OrgInfoId] [int] NULL,
 CONSTRAINT [PK_Car] PRIMARY KEY CLUSTERED
(
    [CarId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO


table 2
============
SQL
CREATE TABLE [mst].[Dealer](
    [DealerId] [int] IDENTITY(1,1) NOT NULL,
    [DealerName] [nvarchar](250) NULL,
    [Location] [nvarchar](50) NULL,
    [SpocPerson] [nvarchar](250) NULL,
    [ContactNo] [nvarchar](50) NULL,
    [IsAction] [bit] NOT NULL,
   
 CONSTRAINT [PK_Dealer] PRIMARY KEY CLUSTERED
(
    [DealerId] 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


table 3
===============
SQL
CREATE TABLE [mst].[Model](
    [ModelId] [int] IDENTITY(1,1) NOT NULL,
    [ModelName] [nvarchar](250) NULL,
    [BrandId] [int] NOT NULL,
    [IsAction] [bit] NOT NULL,
   
 CONSTRAINT [PK_Model] PRIMARY KEY CLUSTERED
(
    [ModelId] 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


out put can this format
==================
Model Total On Loan Available
Passat 1 1 0
Jetta 1 1 0
Sharan 1 1 0
Scirocco 1 0 1


available colum can total - onloan
Posted
Comments
E.F. Nijboer 9-Jul-15 3:48am    
Looks like you already got your answer, so no need to use sql at all.. otherwise, this is a school assignment and you should do it yourself to learn something.
cybie04 9-Jul-15 3:53am    
Or at least Tag it as "Homework". Also column definition for your required output is unclear.
Herman<T>.Instance 21-Jul-15 9:55am    
what are the requirements for column OnLoan?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900