Jump to content

SQL server query experts pls come here


Recommended Posts

Posted

I have a query which pulls 207K records,

i have to add 2 columns (month and year will be columns ) for the last 2 years 

 

a,b,c are  columns from query1 , month and year will be from query 2

 i need same rows from query1 and query 2  rows change with month and year

ila undhali result set 

a|b|c                  |month|year

207 records ki  a|b|c|nov|2019

same 207k records   a|b|c|oct|2019

and so on  upto last 2 years which will be a|b|c|nov|2017

 

so total records will be 207K * 24 =5,589 K records

Posted
 
2
3
DELETE FROM table
WHERE
    condition;


 

works only in production _-_

Posted
2 minutes ago, WigsandThighs said:
 
2
3
DELETE FROM table
WHERE
    condition;


 

works only in production _-_

lol,

production ki andhuke only read access istharu .....

Posted
11 minutes ago, Tech_Babu said:

look up examples on cross join

adhe try chestuna bro, 1 hr run ayyi time out avthundi

Posted
1 minute ago, naaistamrabhai said:

question ardam kale...tables endi...data endi...

Table 1       Table 2

a|b|c|           oct|2019

 

after query

Table 1

a|b|c|oct|2019

a|b|c|sep|2019

a|b|c|aug|2019

.......

a|b|c|oct|2017

Posted
1 minute ago, Spartan said:

Table 1       Table 2

a|b|c|           oct|2019

 

after query

Table 1

a|b|c|oct|2019

a|b|c|sep|2019

a|b|c|aug|2019

.......

a|b|c|oct|2017

join cheste set kada on the primary key 

wht do u need simple no 

Posted
1 hour ago, Rabbo said:

I have a query which pulls 207K records,

i have to add 2 columns (month and year will be columns ) for the last 2 years 

 

a,b,c are  columns from query1 , month and year will be from query 2

 i need same rows from query1 and query 2  rows change with month and year

ila undhali result set 

a|b|c                  |month|year

207 records ki  a|b|c|nov|2019

same 207k records   a|b|c|oct|2019

and so on  upto last 2 years which will be a|b|c|nov|2017

 

so total records will be 207K * 24 =5,589 K records

U should not do that...asal req endi sakkaga seppu jara

Posted
Just now, kevinUsa said:

join cheste set kada on the primary key 

wht do u need simple no 

nen only req cheppa..i know no details.

Posted
1 hour ago, Rabbo said:

I have a query which pulls 207K records,

i have to add 2 columns (month and year will be columns ) for the last 2 years 

 

a,b,c are  columns from query1 , month and year will be from query 2

 i need same rows from query1 and query 2  rows change with month and year

ila undhali result set 

a|b|c                  |month|year

207 records ki  a|b|c|nov|2019

same 207k records   a|b|c|oct|2019

and so on  upto last 2 years which will be a|b|c|nov|2017

 

so total records will be 207K * 24 =5,589 K records

You will add columns ( year and month) based on identifier on Table B. 

Is that identifier in table A? 

If so just join on that column. 

 

Posted
1 hour ago, Spartan said:

Table 1       Table 2

a|b|c|           oct|2019

 

after query

Table 1

a|b|c|oct|2019

a|b|c|sep|2019

a|b|c|aug|2019

.......

a|b|c|oct|2017

Question baga ardam ayyindhi neeku

Answer cheppu  bro ..

cross join use cheste time out avthundi 

table 2 is just generating month and year for last 2 years 

 

Posted
1 hour ago, Amrita said:

You will add columns ( year and month) based on identifier on Table B. 

Is that identifier in table A? 

If so just join on that column. 

 

Identifier ledu on table b

Posted
18 minutes ago, Rabbo said:

Question baga ardam ayyindhi neeku

Answer cheppu  bro ..

cross join use cheste time out avthundi 

table 2 is just generating month and year for last 2 years 

 

since there is no common identifier...u can try to do UNION

 

SELECT column1, column2, etc FROM table1
UNION
SELECT column1, column2, etc FROM table2
Posted
2 hours ago, Rabbo said:

I have a query which pulls 207K records,

i have to add 2 columns (month and year will be columns ) for the last 2 years 

 

a,b,c are  columns from query1 , month and year will be from query 2

 i need same rows from query1 and query 2  rows change with month and year

ila undhali result set 

a|b|c                  |month|year

207 records ki  a|b|c|nov|2019

same 207k records   a|b|c|oct|2019

and so on  upto last 2 years which will be a|b|c|nov|2017

 

so total records will be 207K * 24 =5,589 K records

https://stackoverflow.com/questions/1797785/sql-join-two-tables-without-keys-relations

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...