SQL SERVER(T-SQL)

  • hi all,

    i need to write a store procedure in sql server

    Populate the city_summary table based on the customer and state table.

    cust_idcust_namecust_dobcust_citystate_idcust_phonecust_emailcreated_dtmodified_dt

    1234Tim D2/2/1988Austin20048595098tim@gmail.com3/2/2011

    1235Bill P5/3/1980New York30046748898bill_p@gmail.com4/2/2011

    1278John Q6/13/1988Cheanni40084930393john@gmail.com5/5/2011

    1279John Black6/13/1984Cheanni40084930356john_b@gmail.com5/6/2011

    state_idstate_nmcountry

    200TXUSA

    300NYUSA

    400TNINDIA

    city_summary

    city_namestate_namecountry_nameno_of_customers

    can any one help

  • create table cust(cust_id int,cust_name nvarchar(30),cust_dob datetime, cust_city nvarchar(15) ,state_id int, cust_phone numeric(10,0) ,cust_email nvarchar(100), created_dt datetime, modified_dt datetime)

    Insert into cust values(1234, 'Tim D','2/2/1988','Austin', 200 ,48595098,'tim@gmail.com' ,'3/2/2011','3/2/2011')

    Insert into cust values(1235, 'Bill P','5/3/1980','New York', 300 ,46748898,'bill_p@gmail.com' ,'4/2/2011','4/2/2011')

    Insert into cust values(1278, 'John Q','6/13/1988','Cheanni', 400 ,84930393,'john@gmail.com' ,'5/5/2011','5/5/2011')

    Insert into cust values(1279, 'John Black','6/13/1984','Cheanni', 400 ,84930356,'john_b@gmail.com' ,'5/6/2011','5/6/2011')

    create table states (state_id int,state_nm nvarchar(20), country nvarchar(20))

    Insert into states values(200,'TX','USA'),(300 ,'NY','USA'),(400,'TN','INDIA')

    Select cust_city,state_nm,country,COUNT(cust_id)no_of_customers from cust C Inner join states s on S.state_id=C.state_id group by cust_city,S.state_id,state_nm,country

  • hi

    Thanx to reply

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply