Jump to content

Sql Experts Need Idea


Recommended Posts

Posted

Oka table nundi quarter one data techkuntuna and amount column lo 100 undi oka row lo
So I will create csv file using ssis --- easy

2nd quarter lo amount column lo current quarter minus previous quarter kavali
Example : 2nd quarter 150 ankundam so amount column lo 150-100 = 50 ravali output ... Experts need logic ...meanwhile I try

Posted

designate negative sign to all amounts in quarter 1..

then 

add em up in quarter 2

 

or 

bring in quarter 1 amounts for all the reocords in quarter2 report also...then u can use the operations for desired result

Posted

designate negative sign to all amounts in quarter 1..
then
add em up in quarter 2

or
bring in quarter 1 amounts for all the reocords in quarter2 report also...then u can use the operations for desired result


Clarity ledu bro
Posted

Lookup lo previous quarter teskuna and derived column lo substract chesa.... Is there any thing we can do sql query itself ???

Posted

Lookup lo previous quarter teskuna and derived column lo substract chesa.... Is there any thing we can do sql query itself ???

query lo ney subtract cheyochu ga..

 

Q1AMT-Q2AMT as NET_BAL

ani

Posted

query lo ney subtract cheyochu ga..

Q1AMT-Q2AMT as NET_BAL
ani

Select amount from table
Where date = '2015-3-31'

Select amount from table
Where date = '2015-6-30'

Now write it down in one query.. My query has too many tables and joins but just looking for logic ante...

2 quarter lo run chesinapudu amount should be deducted from previous quarter

It should repeats for all 4 quarters
Posted

Select amount from table
Where date = '2015-3-31'

Select amount from table
Where date = '2015-6-30'

Now write it down in one query.. My query has too many tables and joins but just looking for logic ante...

2 quarter lo run chesinapudu amount should be deducted from previous quarter

It should repeats for all 4 quarters

 

 

with q1 as (Select amount q1amt from table
Where date = '2015-3-31'),

q2 as

(Select amount q2amt from table
Where date = '2015-6-30')

select q2.q2amt - q1.q1amt from q1,q2;

Posted

Select amount from table
Where date = '2015-3-31'

Select amount from table
Where date = '2015-6-30'

Now write it down in one query.. My query has too many tables and joins but just looking for logic ante...

2 quarter lo run chesinapudu amount should be deducted from previous quarter

It should repeats for all 4 quarters

 

with 

 

Q1Data as

(

Select UNQ IDQ1, amount as AMTQ1 from table A
Where date = '2015-3-31')

,

Q2Data as

(
Select UNQ IDQ2, amount as AMT Q2  from table B
Where date = '2015-6-30')

 

select UNQ_IDQ1, UNQ_IDQ2, AMTQ1, AMTQ2, AMTQ1-AMTQ1 as NET_AMT

from Q1Data, Q2Data

where Q1Data.UNQ_IDQ1 = Q2data.UNQ_IDQ2

Posted

with

Q1Data as
(
Select UNQ IDQ1, amount as AMTQ1 from table A
Where date = '2015-3-31')
,
Q2Data as
(
Select UNQ IDQ2, amount as AMT Q2 from table B
Where date = '2015-6-30')

select UNQ_IDQ1, UNQ_IDQ2, AMTQ1, AMTQ2, AMTQ1-AMTQ1 as NET_AMT
from Q1Data, Q2Data
where Q1Data.UNQ_IDQ1 = Q2data.UNQ_IDQ2


Cool
Posted

with q1 as (Select amount q1amt from table
Where date = '2015-3-31'),
q2 as
(Select amount q2amt from table
Where date = '2015-6-30')
select q2.q2amt - q1.q1amt from q1,q2;


Cte thought ye rala..cool thanks
Posted

One more doubt ....
Every year 1st quarter ki only 1st quarter data ne ravali... Ipuduna logic vadite... 2016 1st quarter ki it substracts 2016 1st quarter from 2015 last quarter... So any ideas?? Will try parallel .. Idea vaste post it Bros

Posted

Naa idea ite ... If month less than 6 unte uses other query and > 6 ite use this cte thing ? If it works or any better ideas... Just asking my logic don't looks like shit if I presents to others.

Posted

One more doubt ....
Every year 1st quarter ki only 1st quarter data ne ravali... Ipuduna logic vadite... 2016 1st quarter ki it substracts 2016 1st quarter from 2015 last quarter... So any ideas?? Will try parallel .. Idea vaste post it Bros

 

nee query lo from, end dates pettadaniki chance leda? general ga ila undali

 

Select amount q1amt from table
Where date between '2016-01-01' and  '2016-3-31'

×
×
  • Create New...