Medhadu ki metha SQL query Chalanachithram.com | Topics | Search
Hide Clipart | Log Out | Register | Edit Profile

Last 30 mins | 1 | 2 | 4 hours     Last 1 | 7 Days

Chalanachithram.com DB » TF Industry related » Archive through September 11, 2009 » Medhadu ki metha SQL query « Previous Next »

Author Message
Top of pagePrevious messageNext messageBottom of page Link to this message

Chasing_perfection
Junior Artist
Username: Chasing_perfection

Post Number: 49
Registered: 04-2009
Posted From: 75.189.149.195

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 09:27 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Gotcha:




yeah...first example chusthe konchem idea vachindi...
Top of pagePrevious messageNext messageBottom of page Link to this message

Gotcha
Side Hero
Username: Gotcha

Post Number: 4017
Registered: 02-2008
Posted From: 98.206.204.119

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 09:22 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Chasing_perfection:


yeah. simple group by to ayopyedi if the other column is just some aggregate like max, min, sum, count etc but its not aggreagate so the issue.
Top of pagePrevious messageNext messageBottom of page Link to this message

Chasing_perfection
Junior Artist
Username: Chasing_perfection

Post Number: 48
Registered: 04-2009
Posted From: 75.189.149.195

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 09:20 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Gotcha:




ento simple group by tho ayipothundhi anukunnna...kani intha vuntundhi anukole...
Top of pagePrevious messageNext messageBottom of page Link to this message

Gotcha
Side Hero
Username: Gotcha

Post Number: 4014
Registered: 02-2008
Posted From: 98.206.204.119

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 09:11 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Chasing_perfection:


nuvvu ichindi very correct link. it will surely help driver ramudu anukuntuna, chala methods ichadu aa link lo.
Top of pagePrevious messageNext messageBottom of page Link to this message

Chasing_perfection
Junior Artist
Username: Chasing_perfection

Post Number: 46
Registered: 04-2009
Posted From: 75.189.149.195

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 09:00 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Gotcha:




emo anna ...naku ayithe okka mukka ardam kaledhu kani koncem similar scenario anipinchi ichanu...
Top of pagePrevious messageNext messageBottom of page Link to this message

Gotcha
Side Hero
Username: Gotcha

Post Number: 4013
Registered: 02-2008
Posted From: 98.206.204.119

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 08:56 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Chasing_perfection:


this is what i was saying by using cross apply.





The blackbox XML methods

Here is a technique for string concatenation that uses the FOR XML clause with PATH mode. It was initially posted by Eugene Kogan, and later became common in public newsgroups.

SELECT p1.CategoryId,
( SELECT ProductName + ','
FROM Northwind.dbo.Products p2
WHERE p2.CategoryId = p1.CategoryId
ORDER BY ProductName
FOR XML PATH('') ) AS Products
FROM Northwind.dbo.Products p1
GROUP BY CategoryId ;

There is a similar approach that was originally found in the beta newsgroups, using the CROSS APPLY operator.

SELECT DISTINCT CategoryId, ProductNames
FROM Northwind.dbo.Products p1
CROSS APPLY ( SELECT ProductName + ','
FROM Northwind.dbo.Products p2
WHERE p2.CategoryId = p1.CategoryId
ORDER BY ProductName
FOR XML PATH('') ) D ( ProductNames )
You may notice a comma at the end of the concatenated string, which you can remove using a STUFF, SUBSTRING or LEFT function. While the above methods are deemed reliable by many at the time of writing, there is no guarantee that it will stay that way, given that the internal workings and evaluation rules of FOR XML PATH() expression in correlated subqueries are not well documented.
Top of pagePrevious messageNext messageBottom of page Link to this message

Chasing_perfection
Junior Artist
Username: Chasing_perfection

Post Number: 45
Registered: 04-2009
Posted From: 75.189.149.195

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 08:53 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Driverramudu:




http://www.simple-talk.com/sql/t-sql-programming/concatenati ng-row-values-in-transact-sql/

anna...hope this helps...I am not sure though
Top of pagePrevious messageNext messageBottom of page Link to this message

Gotcha
Side Hero
Username: Gotcha

Post Number: 4010
Registered: 02-2008
Posted From: 98.206.204.119

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 08:20 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

actually there is a method in sql 2k5 for the reverse of it called cross over. what ur looking for is opposite of cross over. my guess scalar is he only way.
Top of pagePrevious messageNext messageBottom of page Link to this message

Gotcha
Side Hero
Username: Gotcha

Post Number: 4009
Registered: 02-2008
Posted From: 98.206.204.119

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 08:19 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

use group by and then use a scalar function to combine.

it wont take 2 minutes ur logic must be wrong somehwere.
Top of pagePrevious messageNext messageBottom of page Link to this message

Driverramudu
Comedian
Username: Driverramudu

Post Number: 1897
Registered: 02-2009
Posted From: 166.205.134.8

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 08:07 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Gotcha:




i tried but prob with pivot is we have to
hardcode section names which i dont
want. Also it is meant for showing
columns as rows and row values as column
names
Driving is my PASSION. Ball or Bmmer does not matter
Top of pagePrevious messageNext messageBottom of page Link to this message

Gotcha
Side Hero
Username: Gotcha

Post Number: 4008
Registered: 02-2008
Posted From: 98.206.204.119

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 08:03 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

try to use SQL PIVOT its easy and its a new feature of sql 2k5
Top of pagePrevious messageNext messageBottom of page Link to this message

Driverramudu
Comedian
Username: Driverramudu

Post Number: 1896
Registered: 02-2009
Posted From: 166.205.134.8

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 07:55 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Wrathchild:




yep i trief many ways like

using outer apply and partiion clauses

some how related section names are
not concatenetef with comma
Driving is my PASSION. Ball or Bmmer does not matter
Top of pagePrevious messageNext messageBottom of page Link to this message

Wrathchild
Side Hero
Username: Wrathchild

Post Number: 8488
Registered: 03-2009
Posted From: 69.136.172.251

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 07:46 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Driverramudu:




SQL SERVER lo partition by clause etc support unda?
Top of pagePrevious messageNext messageBottom of page Link to this message

Driverramudu
Comedian
Username: Driverramudu

Post Number: 1895
Registered: 02-2009
Posted From: 166.205.132.112

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 07:44 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Wrathchild:




here we r using sql server 2K5
we r not allowed to use those technologies
as its not feasble to do
Driving is my PASSION. Ball or Bmmer does not matter
Top of pagePrevious messageNext messageBottom of page Link to this message

Wrathchild
Side Hero
Username: Wrathchild

Post Number: 8487
Registered: 03-2009
Posted From: 69.136.172.251

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 07:40 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Driverramudu:




deeniki best approach..table ni flat file ki dump kotti perl/awk lo script raste super fast aipotundi..let me check..i used this before in perl/awk
Top of pagePrevious messageNext messageBottom of page Link to this message

Wrathchild
Side Hero
Username: Wrathchild

Post Number: 8486
Registered: 03-2009
Posted From: 69.136.172.251

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 07:39 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Driverramudu:

section no. Name
11. Aa
11. Bb
11. Cc
22. Dd
22. Ee
22. Ff

finally output should be

sectionno. Names
11. Aa,bb,cc
22. Dd,ee,ff




ee req ki nuvvu phrase chesina question ki asalu connection unda
Top of pagePrevious messageNext messageBottom of page Link to this message

Driverramudu
Comedian
Username: Driverramudu

Post Number: 1894
Registered: 02-2009
Posted From: 166.205.132.112

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 07:38 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

Also i neither wann use cursor nor procedural aproach

i just wann write logic in just query. I.e. Relational approach

xample data

section no. Name
11. Aa
11. Bb
11. Cc
22. Dd
22. Ee
22. Ff

finally output should be

sectionno. Names
11. Aa,bb,cc
22. Dd,ee,ff

note here rows are not fixed if more
sections avail then output also
increases accordingly
Driving is my PASSION. Ball or Bmmer does not matter
Top of pagePrevious messageNext messageBottom of page Link to this message

Wrathchild
Side Hero
Username: Wrathchild

Post Number: 8485
Registered: 03-2009
Posted From: 69.136.172.251

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 07:35 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

clear ga ledu nee question..order by section number kottachuga
Top of pagePrevious messageNext messageBottom of page Link to this message

Driverramudu
Comedian
Username: Driverramudu

Post Number: 1893
Registered: 02-2009
Posted From: 166.205.132.112

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 07:28 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

Using scalar function i wrote query
but its taking 2minuted 30seconds to return
540K + rows. My objective is max 5 seconds
as of now
Driving is my PASSION. Ball or Bmmer does not matter
Top of pagePrevious messageNext messageBottom of page Link to this message

Driverramudu
Comedian
Username: Driverramudu

Post Number: 1892
Registered: 02-2009
Posted From: 166.205.132.112

Rating: N/A
Votes: 0 (Vote!)

Posted on Thursday, September 10, 2009 - 07:24 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

I got a table and it is having 2 columns.
They are Section no and studentname.

Now the requirement is
i wann display all the student names under
each section

without using scalar function. This is must
Driving is my PASSION. Ball or Bmmer does not matter

Add Your Message Here
Post:
Bold text Italics Underline Create a hyperlink Insert a clipart image HASH(0x9749648){Movie Clipart}
Show / Hide regular icons selection options

Click on following links to open cliparts by Alphabetical Order

 A   B   C   D   E   F   G   H   I   J   K   L   M  

 N   O   P   Q   R   S   T   U   V   W   X   Y   Z  

Show / Hide Filmy icons selection options

Click on following links to open cliparts by Alphabetical Order

 A   B   C   D   E   F   G   H   I   J   K   L   M  

 N   O   P   Q   R   S   T   U   V   W   X   Y   Z  


Username: Posting Information:
This is a public posting area. Enter your username and password if you have an account. Otherwise, enter your full name as your username and leave the password blank. Your e-mail address is optional.
Password:
E-mail:
Options: Enable HTML code in message
Automatically activate URLs in message
Action: