• richesflow (9/2/2012)


    I need to display the Name of all US-based, Japan-based and German-based suppliers. Order the results by Name in ascending order. Can you help me?

    Hello and welcome to the site.

    for future reference you will find that for the majority of questions it is helpful to us and you if you can provide some example background details...this is often referred to as DDL / insert scripts......if you arent sure how to do this please post back.

    below is some sample code that you can paste into SSMS and run.

    USE [tempdb]

    GO

    -- create a table and insert some data to demonstrate what I am talking about

    -- this will allow potential helpers to easily provide thoughts and solutions

    IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Suppliers]') AND type in (N'U'))

    DROP TABLE [dbo].[Suppliers]

    GO

    CREATE TABLE [dbo].[Suppliers](

    [Supplier_ID] [int] IDENTITY(1,1) NOT NULL,

    [Supplier_name] [varchar](50) NULL,

    [Supplier_country] [varchar](50) NULL,

    CONSTRAINT [PK_SUPPLIERS] PRIMARY KEY CLUSTERED

    (

    [Supplier_ID] ASC

    )) ON [PRIMARY]

    GO

    SET IDENTITY_INSERT [dbo].[Suppliers] ON;

    INSERT INTO [dbo].[Suppliers]([Supplier_ID], [Supplier_name], [Supplier_country])

    SELECT 1, N'Acme Trade', N'Japan' UNION ALL

    SELECT 2, N'Xyzzy Co', N'Germany' UNION ALL

    SELECT 3, N'Zeus and Company', N'UK' UNION ALL

    SELECT 4, N'Lincoln Inc', N'USA' UNION ALL

    SELECT 5, N'Whamo Widgets', N'USA' UNION ALL

    SELECT 6, N'MoCarCo', N'Germany'

    SET IDENTITY_INSERT [dbo].[Suppliers] OFF;

    -- here is some code that might provide some ideas.

    SELECT Supplier_name, Supplier_country

    FROM SUPPLIERS

    WHERE (Supplier_country IN ('Germany', 'USA'))

    ORDER BY Supplier_country, Supplier_name

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day