Welcome to Sign in | Help
in Search

select mai ciudat.

Last post 10-20-2006, 10:10 PM by ggciubuc. 3 replies.
Sort Posts: Previous Next
  •  10-19-2006, 1:10 PM 441

    select mai ciudat.

    Am nevoie de un select mai ciudat (sql server 2000) care ar fi ceva de genul : select (select count(item1) from tabela where cond1 as rezultat1), (select count(item2) from tabela where cond2 as rezultat2), (select count(item3) from tabela where cond3 as rezultat3), item4 from tabela group by item4 imi intoarce rezultatele multipilcate. E posibil sa construiesc un astfel de select ? Pe mine ma inteereseaza o sumarizare a rezultatelor pentru fiecare valoare a lui item4.
    Filed under:
  •  10-19-2006, 1:29 PM 445 in reply to 441

    Re: select mai ciudat.

    Realizati ceva similar cu

    select Year,

    sum (CASE Quarter WHEN 1 THEN Amount ELSE 0 END) as Trim1,

    sum (CASE Quarter WHEN 2 THEN Amount ELSE 0 END) as Trim2,

    sum (CASE Quarter WHEN 3 THEN Amount ELSE 0 END) as Trim3,

    sum (CASE Quarter WHEN 4 THEN Amount ELSE 0 END) as Trim4

    from Northwind.dbo.Tabel

    Group by YEAR

     

    face sumarizare pe trimestre.

    Dvs faceti numarare, in conditiile in care item1 are niste valori discrete de un nr. redus. 

     


    Gheorghe Ciubuc,SQL Server Influencer, MCP(SQL 2000), MCTS (SQL Server 2005) , OCA(Oracle 9i), Sybase(Brainbench)
  •  10-20-2006, 2:37 PM 453 in reply to 445

    Re: select mai ciudat.

    Am rezolvat facind un inner join de genul : select distinct r1.r, r2.r, r3.r, item4 from tabela inner join (select count( * ) r, item4 from tabela where conditie group by item4) r1 on tabela.item4 = r1.item4 .... inner join (...) r2 on tabela.item4 = r2.item4
  •  10-20-2006, 10:10 PM 458 in reply to 453

    Re: select mai ciudat.

    Viteza? Indecsii?
    Gheorghe Ciubuc,SQL Server Influencer, MCP(SQL 2000), MCTS (SQL Server 2005) , OCA(Oracle 9i), Sybase(Brainbench)
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems