<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlserver.ro/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>T-SQL</title><link>http://sqlserver.ro/forums/15/ShowForum.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Re: scrip de select sql server 2000</title><link>http://sqlserver.ro/forums/thread/2290.aspx</link><pubDate>Tue, 17 Jul 2007 15:52:10 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2290</guid><dc:creator>Alex</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2290.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2290</wfw:commentRss><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://sqlserver.ro/Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;B_gd_n[ ]Sahlean:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://sqlserver.ro/Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;Alex:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;eu sunt f lamurit :).....mai putin la problema 2 ;)

oricum......Unitate teritoriala se intelege clar ca e vorba de Judet :)

"O aplicatie are nevoie de date privind populatia Europei detaliate la nivel de tara, unitate administrativ-teritoriale(judet) si localitate. " (din enuntul problemei)

multumesc mult

alex.&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Nu am citit decat primul mesaj. Problema e ca ai facut din start (primul mesaj) o prezentare ERONATA / INCOMPLETĂ a problemei. Daca vrei sa obtii o solutie la problema trebuie SĂ ŞTII CE SĂ CERI !&amp;nbsp; &lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;&lt;p&gt;intradevar primele mele cerinte au fost destul de neclare.....scuze pt asta.....&lt;br&gt;&lt;/p&gt;&lt;p&gt;am crezut ca daca vorbesti despre "unitate teritoriala"&amp;nbsp; ai citit si postul cu textul exact al problemei unde se specifica exact la ce se refera "unitate teritoriala(judet)"......&lt;/p&gt;&lt;p&gt;&amp;nbsp;multumesc mult.&lt;/p&gt;&lt;p&gt;alex.&lt;br&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: scrip de select sql server 2000</title><link>http://sqlserver.ro/forums/thread/2289.aspx</link><pubDate>Tue, 17 Jul 2007 14:07:36 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2289</guid><dc:creator>B_gd_n[ ]Sahlean</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2289.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2289</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://sqlserver.ro/Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;Alex:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;eu sunt f lamurit :).....mai putin la problema 2 ;)

oricum......Unitate teritoriala se intelege clar ca e vorba de Judet :)

"O aplicatie are nevoie de date privind populatia Europei detaliate la nivel de tara, unitate administrativ-teritoriale(judet) si localitate. " (din enuntul problemei)

multumesc mult

alex.&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Nu am citit decat primul mesaj. Problema e ca ai facut din start (primul mesaj) o prezentare ERONATA / INCOMPLETĂ a problemei. Daca vrei sa obtii o solutie la problema trebuie SĂ ŞTII CE SĂ CERI !&amp;nbsp; &lt;br&gt;&lt;/p&gt;</description></item><item><title>Re: scrip de select sql server 2000</title><link>http://sqlserver.ro/forums/thread/2288.aspx</link><pubDate>Tue, 17 Jul 2007 13:40:29 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2288</guid><dc:creator>Alex</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2288.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2288</wfw:commentRss><description>eu sunt f lamurit :).....mai putin la problema 2 ;)

oricum......Unitate teritoriala se intelege clar ca e vorba de Judet :)

"O aplicatie are nevoie de date privind populatia Europei detaliate la nivel de tara, unitate administrativ-teritoriale(judet) si localitate. " (din enuntul problemei)

multumesc mult

alex.</description></item><item><title>Re: scrip de select sql server 2000</title><link>http://sqlserver.ro/forums/thread/2286.aspx</link><pubDate>Tue, 17 Jul 2007 10:47:17 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2286</guid><dc:creator>B_gd_n[ ]Sahlean</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2286.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2286</wfw:commentRss><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://sqlserver.ro/Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;katalyn:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;Cerinţa este: "Cea mai populata unitate teritoriala &lt;u&gt;din fiecare tara&lt;/u&gt;, populatia ei si tara de care apartine"&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;În fine, sper că Alex a fost lămurit indiferent de care este cerinţa corectă.&lt;/p&gt;&lt;p&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;&lt;p&gt;Acest enunt este eronat pentru ca:&lt;/p&gt;&lt;p&gt;[1] expresia este "unitate teritoriala" este&amp;nbsp; neclară: UT&amp;nbsp; = J sau UT = L sau UT = J + L &lt;/p&gt;&lt;p&gt;[2] pp. ca UT se refera la - virgula -&amp;nbsp; localitati atunci pot exista (cel putin teoretic) mai multe L din aceeasi T cu aceeasi populatie (nr. locuitori) si aceasta populatia sa fie maxima la nivelul tarii respective:&lt;/p&gt;&lt;p&gt;LOC_A&amp;nbsp; --- TARA_X --- 100.000&lt;/p&gt;&lt;p&gt;LOC_B --- TARA_X --- 100.00&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;u&gt;&lt;b&gt;Care sunt cele mai populate localitati (nr. &lt;/b&gt;&lt;/u&gt;&lt;u&gt;&lt;b&gt;maxim de &lt;/b&gt;&lt;/u&gt;&lt;u&gt;&lt;b&gt;locuitori) din fiecare tara, populatia lor si tara de care apartin ?&lt;br&gt;&lt;/b&gt;&lt;/u&gt;&lt;/p&gt;&lt;p&gt;In acest caz solutia este cea prezentata anterior (s-a avut in vedere inc. faptul ca la nivelul unei tari pot exista m. multe localitati cu acelasi nr. de locuitori, nr. de locuitori fiind maxim):&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;lt;solutie&amp;gt;&amp;nbsp;&lt;/b&gt;&lt;/p&gt;SELECT T.nume_tara, J.nume_judet, L.nume_loc, MAX(L.nr_locuitori) AS Nr&lt;br&gt;FROM Localitate L INNER JOIN Judet J ON L.id_judet = J.id_judet&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; INNER JOIN Tara T ON J.id_tara = T.id_tara&lt;br&gt;GROUP BY T.id_tara, L.id_loc , T.nume_tara, J.nume_judet, L.nume_loc&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HAVING MAX(L.nr_locuitori) &amp;gt;= &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ALL(SELECT LSQ.nr_locuitori &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; FROM Localitate LSQ INNER JOIN Judet JSQ ON LSQ.id_judet = JSQ.id_judet &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE JSQ.id_tara = T.id_tara )&lt;br&gt;&lt;p&gt;&lt;b&gt;&amp;lt;/solutie&amp;gt; &lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: scrip de select sql server 2000</title><link>http://sqlserver.ro/forums/thread/2285.aspx</link><pubDate>Tue, 17 Jul 2007 10:28:59 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2285</guid><dc:creator>katalyn</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2285.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2285</wfw:commentRss><description>&lt;P&gt;Cerinţa este: "Cea mai populata unitate teritoriala &lt;U&gt;din fiecare tara&lt;/U&gt;, populatia ei si tara de care apartine"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;În fine, sper că Alex a fost lămurit indiferent de care este cerinţa corectă.&lt;/P&gt;</description></item><item><title>Re: scrip de select sql server 2000</title><link>http://sqlserver.ro/forums/thread/2284.aspx</link><pubDate>Tue, 17 Jul 2007 10:05:11 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2284</guid><dc:creator>B_gd_n[ ]Sahlean</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2284.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2284</wfw:commentRss><description>---</description></item><item><title>Re: scrip de select sql server 2000</title><link>http://sqlserver.ro/forums/thread/2283.aspx</link><pubDate>Tue, 17 Jul 2007 10:02:19 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2283</guid><dc:creator>B_gd_n[ ]Sahlean</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2283.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2283</wfw:commentRss><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://sqlserver.ro/Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;katalyn:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;Eu am înţeles că este vorba de a selecta fiecare ţara cu judeţul cel mai populat şi numărul de locuitori.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;b&gt;B_gd_n[ ]Sahlean&amp;nbsp; &lt;/b&gt;în prima variantă aflăm doar ţara care are cel mai populat judeţ (de fapt aflăm ţara cu judeţul ce deţine localitatea cu cel mai mare număr de locuitori dar nu este tratat cazul în care avem două localităţi în acelaşi oraş). În a 2-a variantă nu este tratat cazul în care există două sau mai multe localităţi intr-un judeţ.&lt;br&gt;&amp;nbsp;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;[1]&lt;/b&gt; Cerinţa din primul mesaj este: "&lt;b&gt;as dori sa fac un select care sa-mi intoarca [...] localitatilor cu cel mai mare numar de locuitori&lt;/b&gt;"&lt;/p&gt;&lt;p&gt;Cerinţa este foarte clară şi nu implică condiţii privitoare la ţară sau/şi judeţ. Ai interpretat eronat enunţul.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;[2]&lt;/b&gt; Vezi mesajul anterior. Cerinţa era foarte clară şi tu ai interpretat-o eronat.&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: scrip de select sql server 2000</title><link>http://sqlserver.ro/forums/thread/2282.aspx</link><pubDate>Tue, 17 Jul 2007 09:49:52 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2282</guid><dc:creator>B_gd_n[ ]Sahlean</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2282.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2282</wfw:commentRss><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://sqlserver.ro/Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;katalyn:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;&amp;nbsp;... două localităţi în acelaşi oraş ...&lt;br&gt;&lt;/p&gt;&lt;p&gt; &lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;?&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;br&gt;Poate vrei sa spui "două localităţi în acelaşi judet"&amp;nbsp; ?!&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;lt;date_test&amp;gt;&lt;/b&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;UPDATE Localitate&lt;br&gt;SET nr_locuitori = 330&lt;br&gt;WHERE nume_loc = 'L_E'&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;lt;/date_test&amp;gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;lt;set_inregistrari_rezultat&amp;gt;&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;L_E&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;i&gt;&lt;b&gt;J_C&lt;/b&gt;&lt;/i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BB&amp;nbsp;&amp;nbsp;&amp;nbsp; 330&lt;br&gt;L_F&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;i&gt;&lt;b&gt;J_C&lt;/b&gt;&lt;/i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BB&amp;nbsp;&amp;nbsp;&amp;nbsp; 330&lt;br&gt;L_K&amp;nbsp;&amp;nbsp;&amp;nbsp; J_E&amp;nbsp;&amp;nbsp;&amp;nbsp; BB&amp;nbsp;&amp;nbsp;&amp;nbsp; 330&amp;nbsp; &lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;lt;/set_inregistrari_rezultat&amp;gt;&lt;/b&gt; &lt;br&gt;&lt;/p&gt;</description></item><item><title>Re: scrip de select sql server 2000</title><link>http://sqlserver.ro/forums/thread/2281.aspx</link><pubDate>Tue, 17 Jul 2007 09:21:19 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2281</guid><dc:creator>katalyn</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2281.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2281</wfw:commentRss><description>&lt;P&gt;Eu am înţeles că este vorba de a selecta fiecare ţara cu judeţul cel mai populat şi numărul de locuitori.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;STRONG&gt;B_gd_n[ ]Sahlean&amp;nbsp; &lt;/STRONG&gt;în prima variantă aflăm doar ţara care are cel mai populat judeţ (de fapt aflăm ţara cu judeţul ce deţine localitatea cu cel mai mare număr de locuitori dar nu este tratat cazul în care avem două localităţi în acelaşi oraş). În a 2-a variantă nu este tratat cazul în care există două sau mai multe localităţi intr-un judeţ.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description></item><item><title>Re: scrip de select sql server 2000</title><link>http://sqlserver.ro/forums/thread/2280.aspx</link><pubDate>Tue, 17 Jul 2007 08:49:35 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2280</guid><dc:creator>B_gd_n[ ]Sahlean</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2280.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2280</wfw:commentRss><description>&lt;p&gt;Ar fi fost mult mai interesanta urmatoarea cerinta: &lt;/p&gt;&lt;p&gt;&lt;b&gt;"&lt;font face="Arial" size="2"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;select care sa-mi intoarca tara,nume_judet,localitate al localitatilor cu cel mai mare numar de locuitori&lt;/span&gt;&lt;/font&gt;" &lt;u&gt;&lt;i&gt;din fiecare ţară&lt;/i&gt;&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;lt;solutie&amp;gt;&amp;nbsp;&lt;/b&gt;&lt;/p&gt;SELECT T.nume_tara, J.nume_judet, L.nume_loc, MAX(L.nr_locuitori) AS Nr&lt;br&gt;FROM Localitate L INNER JOIN Judet J ON L.id_judet = J.id_judet&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; INNER JOIN Tara T ON J.id_tara = T.id_tara&lt;br&gt;GROUP BY T.id_tara, L.id_loc , T.nume_tara, J.nume_judet, L.nume_loc&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HAVING MAX(L.nr_locuitori) &amp;gt;= &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ALL(SELECT LSQ.nr_locuitori &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; FROM Localitate LSQ INNER JOIN Judet JSQ ON LSQ.id_judet = JSQ.id_judet &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE JSQ.id_tara = T.id_tara )&lt;br&gt;&lt;p&gt;&lt;b&gt;&amp;lt;/solutie&amp;gt; &lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;lt;set_de_inregistrari_rezultat&amp;gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp; J_B&amp;nbsp;&amp;nbsp;&amp;nbsp; L_D&amp;nbsp;&amp;nbsp;&amp;nbsp; 200&lt;br&gt;BB&amp;nbsp;&amp;nbsp;&amp;nbsp; J_C&amp;nbsp;&amp;nbsp;&amp;nbsp; L_F&amp;nbsp;&amp;nbsp;&amp;nbsp; 330&lt;br&gt;BB&amp;nbsp;&amp;nbsp;&amp;nbsp; J_E&amp;nbsp;&amp;nbsp;&amp;nbsp; L_K&amp;nbsp;&amp;nbsp;&amp;nbsp; 330 &lt;br&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;b&gt;&amp;lt;/set_de_inregistrari_rezultat&amp;gt;&lt;/b&gt;&lt;/p&gt;</description></item><item><title>Re: scrip de select sql server 2000</title><link>http://sqlserver.ro/forums/thread/2279.aspx</link><pubDate>Tue, 17 Jul 2007 08:11:39 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2279</guid><dc:creator>B_gd_n[ ]Sahlean</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2279.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2279</wfw:commentRss><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://sqlserver.ro/Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;Alex:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;font size="2"&gt;&lt;font face="Arial"&gt; ...&lt;/font&gt;&lt;/font&gt;&lt;p class="MsoNormal"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;as dori sa fac un select care sa-mi intoarca tara,nume_judet,localitate al localitatilor cu cel mai mare numar de locuitori&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;multumesc mult&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;lt;date_test&amp;gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;INSERT INTO Tara (nume_tara,latitudine,longitudine) VALUES ('A',1,1)&lt;br&gt;INSERT INTO Tara (nume_tara,latitudine,longitudine) VALUES ('BB',2,2)&lt;br&gt;&lt;br&gt;INSERT INTO Judet (id_tara,nume_judet,asezare) VALUES (1,'J_A','est')&lt;br&gt;INSERT INTO Judet (id_tara,nume_judet,asezare) VALUES (1,'J_B','est')&lt;br&gt;INSERT INTO Judet (id_tara,nume_judet,asezare) VALUES (2,'J_C','vest')&lt;br&gt;INSERT INTO Judet (id_tara,nume_judet,asezare) VALUES (2,'J_D','nord')&lt;br&gt;INSERT INTO Judet (id_tara,nume_judet,asezare) VALUES (2,'J_E','est')&lt;br&gt;&lt;br&gt;INSERT INTO Localitate (id_judet,nume_loc,nr_locuitori) VALUES (10,'L_A',100)&lt;br&gt;INSERT INTO Localitate (id_judet,nume_loc,nr_locuitori) VALUES (10,'L_B',110)&lt;br&gt;INSERT INTO Localitate (id_judet,nume_loc,nr_locuitori) VALUES (10,'L_C',111)&lt;br&gt;INSERT INTO Localitate (id_judet,nume_loc,nr_locuitori) VALUES (20,'L_D',200)&lt;br&gt;INSERT INTO Localitate (id_judet,nume_loc,nr_locuitori) VALUES (30,'L_E',300)&lt;br&gt;INSERT INTO Localitate (id_judet,nume_loc,nr_locuitori) VALUES (30,'L_F',330)&lt;br&gt;INSERT INTO Localitate (id_judet,nume_loc,nr_locuitori) VALUES (40,'L_G',50)&lt;br&gt;INSERT INTO Localitate (id_judet,nume_loc,nr_locuitori) VALUES (40,'L_H',50)&lt;br&gt;INSERT INTO Localitate (id_judet,nume_loc,nr_locuitori) VALUES (40,'L_I',110)&lt;br&gt;INSERT INTO Localitate (id_judet,nume_loc,nr_locuitori) VALUES (40,'L_J',111)&lt;br&gt;INSERT INTO Localitate (id_judet,nume_loc,nr_locuitori) VALUES (50,'L_K',330) &lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;lt;/date_test&amp;gt;&lt;/b&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;lt;solutie&amp;gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;SELECT L.nume_loc , J.nume_judet , T.nume_tara , L.nr_locuitori&lt;br&gt;FROM Localitate L INNER JOIN Judet J ON L.id_judet = J.id_judet&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; INNER JOIN Tara T ON J.id_tara = T.id_tara&lt;br&gt;WHERE L.nr_locuitori &amp;gt;= ALL(SELECT nr_locuitori FROM Localitate) &lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;lt;/solutie&amp;gt;&lt;/b&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: scrip de select sql server 2000</title><link>http://sqlserver.ro/forums/thread/2278.aspx</link><pubDate>Mon, 16 Jul 2007 17:51:45 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2278</guid><dc:creator>Alex</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2278.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2278</wfw:commentRss><description>&lt;p&gt;daca nu ar fi nevoie de afisarea Nume_judet si ar fi de ajuns Nume_tara, Numar_locuitori ar fi de ajuns selectul:&lt;/p&gt;&lt;p&gt;SELECT NUME_TARA, MAX(NUMAR_LOCUITORI) AS NR_LOCUITORI FROM &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (SELECT NUME_TARA, NUME_JUDET, SUM(NR_LOCUITORI) AS NUMAR_LOCUITORI&lt;br&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; FROM TARA T INNER JOIN JUDET J ON T.ID_TARA=J.ID_TARA INNER JOIN LOCALITATE L ON J.ID_JUDET=L.ID_JUDET&lt;br&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; GROUP BY NUME_TARA, NUME_JUDET) X&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GROUP BY NUME_TARA&lt;/p&gt;&lt;p&gt;care scoate maxim pe tara din suma locuitorilor&amp;nbsp; pe judete :)&lt;/p&gt;&lt;p&gt;alex.&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: scrip de select sql server 2000</title><link>http://sqlserver.ro/forums/thread/2277.aspx</link><pubDate>Mon, 16 Jul 2007 17:26:03 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2277</guid><dc:creator>katalyn</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2277.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2277</wfw:commentRss><description>&lt;P&gt;Uite&amp;nbsp;încă&amp;nbsp;o variantă de rezolvare&amp;nbsp;în care folosesc un inner join&amp;nbsp;între două subinterogări totuşi&amp;nbsp;ce trebuie să se întâmple dacă o ţară are două judeţe cu acelaşi număr de locuitori pe primul loc?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SELECT Q.NUME_TARA, W.NUME_JUDET, Q.NR_LOCUITORI FROM (&lt;BR&gt;&amp;nbsp;SELECT NUME_TARA, MAX(NUMAR_LOCUITORI) AS NR_LOCUITORI FROM (&lt;BR&gt;&amp;nbsp;&amp;nbsp;SELECT NUME_TARA, NUME_JUDET, SUM(NR_LOCUITORI) AS NUMAR_LOCUITORI &lt;BR&gt;&amp;nbsp;&amp;nbsp;FROM TARA T INNER JOIN JUDET J ON T.ID_TARA=J.ID_TARA INNER JOIN LOCALITATE L ON J.ID_JUDET=L.ID_JUDET&lt;BR&gt;&amp;nbsp;&amp;nbsp;GROUP BY NUME_TARA, NUME_JUDET&lt;BR&gt;&amp;nbsp;) X&lt;BR&gt;&amp;nbsp;GROUP BY NUME_TARA&lt;BR&gt;) Q INNER JOIN (&lt;BR&gt;&amp;nbsp;SELECT NUME_TARA, NUME_JUDET, NUMAR_LOCUITORI FROM (&lt;BR&gt;&amp;nbsp;&amp;nbsp;SELECT NUME_TARA, NUME_JUDET, SUM(NR_LOCUITORI) AS NUMAR_LOCUITORI &lt;BR&gt;&amp;nbsp;&amp;nbsp;FROM TARA T INNER JOIN JUDET J ON T.ID_TARA=J.ID_TARA INNER JOIN LOCALITATE L ON J.ID_JUDET=L.ID_JUDET&lt;BR&gt;&amp;nbsp;&amp;nbsp;GROUP BY NUME_TARA, NUME_JUDET&lt;BR&gt;&amp;nbsp;) Y&lt;BR&gt;) W ON Q.NUME_TARA=W.NUME_TARA AND Q.NR_LOCUITORI=W.NUMAR_LOCUITORI&lt;/P&gt;
&lt;P&gt;ORDER BY 1,3 DESC, 2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Datele pentru test:&lt;/P&gt;
&lt;P&gt;INSERT INTO Tara(nume_tara, latitudine, longitudine) VALUES('Romania',0,0)&lt;BR&gt;INSERT INTO Tara(nume_tara, latitudine, longitudine) VALUES('SUA',0,0)&lt;BR&gt;GO&lt;BR&gt;INSERT INTO Judet (ID_Tara,nume_judet, asezare) VALUES (1,'Timis','')&lt;BR&gt;INSERT INTO Judet (ID_Tara,nume_judet, asezare) VALUES (1,'Constanta','')&lt;BR&gt;INSERT INTO Judet (ID_Tara,nume_judet, asezare) VALUES (2,'Denver','')&lt;BR&gt;GO&lt;BR&gt;INSERT INTO Localitate(ID_Judet,nume_loc,nr_locuitori) VALUES(10,'Timisoara mare',250)&lt;BR&gt;INSERT INTO Localitate(ID_Judet,nume_loc,nr_locuitori) VALUES(10,'Timisoara mica',25)&lt;BR&gt;INSERT INTO Localitate(ID_Judet,nume_loc,nr_locuitori) VALUES(20,'Cuza',1250)&lt;BR&gt;INSERT INTO Localitate(ID_Judet,nume_loc,nr_locuitori) VALUES(20,'Mangalia',270)&lt;BR&gt;INSERT INTO Localitate(ID_Judet,nume_loc,nr_locuitori) VALUES(30,'denver',11250)&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;iar rezultatul este:&lt;/P&gt;
&lt;P&gt;NUME_TARA |&amp;nbsp; NUME_JUDET&amp;nbsp;&amp;nbsp; |&amp;nbsp; NR_LOCUITORI&lt;BR&gt;SUA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; Denver&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|&amp;nbsp; 11250&lt;BR&gt;Romania&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; Constanta&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; 1520&lt;/P&gt;
&lt;P&gt;Sper că am înţeles bine cerinţa...&lt;/P&gt;</description></item><item><title>Re: scrip de select sql server 2000</title><link>http://sqlserver.ro/forums/thread/2276.aspx</link><pubDate>Mon, 16 Jul 2007 16:32:34 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2276</guid><dc:creator>Alex</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2276.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2276</wfw:commentRss><description>&lt;p&gt;da...merge f bine si varianta ta........cu tabela temporara....:)&lt;/p&gt;&lt;p&gt;alex.&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: scrip de select sql server 2000</title><link>http://sqlserver.ro/forums/thread/2274.aspx</link><pubDate>Mon, 16 Jul 2007 14:34:30 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2274</guid><dc:creator>Diana</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2274.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2274</wfw:commentRss><description>&lt;p&gt;Multumesc...nu a ajuns inca (?)...&lt;/p&gt;&lt;p&gt;Pentru punctul 3&amp;nbsp; din prima intrebare ("cea mai populata unitate teritoriala.....")&lt;/p&gt;&lt;p&gt;--tabelul temporar cuprinde populatia fiecarui "judet"&amp;nbsp;&lt;/p&gt;&lt;p&gt;DECLARE @t TABLE(id_tara int, id_judet int, pop int)&lt;br&gt;
INSERT INTO @t&lt;br&gt;
SELECT t.id_tara, j.id_judet, SUM(nr_locuitori) AS pop&lt;br&gt;
FROM tara t JOIN Judet j ON t.id_tara = j.id_tara&lt;br&gt;
JOIN Localitate l ON j.id_judet = l.id_judet&lt;br&gt;
GROUP BY t.id_tara, j.id_judet&lt;br&gt;
&lt;/p&gt;&lt;p&gt;-- aici selectez din fiecare tara "judetul" cel mai populat&lt;br&gt;
&lt;/p&gt;&lt;p&gt;
SELECT t.id_tara, t.nume_tara, j.id_judet, j.nume_judet, x.mx&lt;br&gt;
FROM Tara t JOIN Judet j ON t.id_tara = j.id_tara&lt;br&gt;
JOIN (SELECT tmp.id_tara, MAX(pop) AS mx &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM @t AS tmp GROUP BY tmp.id_tara&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ) AS x ON x.id_tara = j.id_tara&lt;br&gt;
JOIN @t tmp ON x.mx = tmp.pop AND j.id_judet = tmp.id_judet &lt;br&gt;
&lt;/p&gt;</description></item></channel></rss>