RcBuilder@walla.com
call centre: 054-5614020

SQL Categories

Posted by: RcBuilder  /   Category: CTE / DBA / SQL / SQL Function / Stored Procedure / System Function   /   No Comments
27
Nov
2014

SQL Categories - OPTION 1 - declare @tbl table(Id int,Name nvarchar(50),Parent int,SubCategories nvarchar(500)) insert into @tbl select 1,'111',0,'' union all select 2,'222',1,',2,5,6,7,13,14,' union all select 3,'333',1,'' union all select 4,'444',1,'' union all select 5,'555',2,'' union all select 6,'666',2,'' union all select 7,'777',2,',7,13,14,' union all select 8,'888',3,'' union all select 9,'999',3,'' union all select 10,'aaa',3,'' union all select 11,'bbb',3,'' union all select 12,'ccc',3,'' union all select 13,'ddd',7,'' union all select 14,'eee',7,'' ------------------------------------ declare @Id int set.

Read more

SQL CTE with insert into Example

Posted by: RcBuilder  /   Category: CTE / DBA / SQL / Stored Procedure   /   No Comments
28
May
2014

SQL CTE with insert into Example declare @Depositors table(BURowID int, FTDDepositors int, Depositors int) ;with CTE_Depositors(OwningBusinessUnit, AccountId, FTDDepositors, Depositors) AS( select OwningBusinessUnit, lv_accountid, COUNT(case when lv_firsttimedeposit = 0 then null else 1 end), COUNT(1) from Leadercapital_MSCRM.dbo.lv_monetarytransactionBase group by OwningBusinessUnit, lv_accountid ) insert into @Depositors select BU.RowID, COUNT(D.FTDDepositors), COUNT(D.Depositors) from @BusinessUnits BU, CTE_Depositors D where BU.BusinessUnitId = D.OwningBusinessUnit -- join -- group by.

Read more

SQL CTE with UNION Example

Posted by: RcBuilder  /   Category: CTE / DBA / SQL / SQL Function / Stored Procedure   /   No Comments
28
May
2014

SQL CTE with UNION Example declare @TradingDataOrders table(TPName nvarchar(100), TradingVolume money) ;with CTE_trades(TPName, TradingVolume) AS( select CAST(ClientNumber AS varchar(10)), Volume from dbo.ClosedTrades where (OpenTime between @dtFrom and @dtTo) OR (CloseTime between @dtFrom and @dtTo) UNION ALL select CAST(ClientNumber AS varchar(10)), Volume from dbo.OpenTrades where OpenTime between @dtFrom and @dtTo ) insert into @TradingDataOrders select * from.

Read more
  • פיתוח מערכות
  • פתרונות טכנולוגים
  • קידום אתרים
  • בניית אתרים