SQL help :(

ad.hasareli

Well-known member
  • Mar 27, 2010
    5,264
    580
    113
    දකුනේ කොල්ලෙක්
    mama gdk try bt wede hari giye nethi nisai help akak illanna hhithuwe plz mata me query(SQL sever 2008) aka liyala dennako loku udwak Machanla

    mekai wenna oni

    table 2k thiyenawa loading and billitem :cool:

    loading table ake lorrystock
    Column aken billitem table ake quntity Column aken adu karala dennakoo......


    like this
    (loading) (billitem)
    lorrystock - quntity = result

    15 - 10 = 5
    13 - 9 = 4


    menna create query aka
    programing language vb.net :yes:

    Code:
    USE [sp]
    GO
    /****** Object:  Table [dbo].[loading]    Script Date: 02/12/2013 08:38:55 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[loading](
        [itemcode] [real] NULL,
        [itemname] [varchar](50) NULL,
        [Loading] [real] NULL,
        [unloading] [real] NULL,
        [lorrystock] [real] NULL,
          [lorry] [nchar](10) NULL,
        [date] [date] NULL
    ) ON [PRIMARY]
    GO
    SET ANSI_PADDING OFF
    GO
    INSERT [dbo].[loading] ([itemcode], [itemname], [Loading], [unloading], [lorrystock], [lorry], [date]) VALUES (5, N'Lemon Puff 100g', 5, 4, 15, N'Lorry 1   ', CAST(0xBB360B00 AS Date))
    INSERT [dbo].[loading] ([itemcode], [itemname], [Loading], [unloading], [lorrystock], [lorry], [date]) VALUES (8, N'Milk Shorties 80g', 5, 1, 13, N'Lorry 1   ', CAST(0xBB360B00 AS Date))
    /****** Object:  Table [dbo].[billitem]    Script Date: 02/12/2013 08:38:55 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[billitem](
        [itemcode] [real] NULL,
        [itemname] [varchar](50) NULL,
        [quntity] [varchar](50) NULL,
        [lorry] [varchar](50) NULL,
        [date] [date] NULL
    ) ON [PRIMARY]
    GO
    SET ANSI_PADDING OFF
    GO
    INSERT [dbo].[billitem] ([itemcode], [itemname], [quntity], [lorry], [date]) VALUES (5, N'Lemon Puff 100g', N'10', N'Lorry 1   ', CAST(0xBB360B00 AS Date))
    INSERT [dbo].[billitem] ([itemcode], [itemname], [quntity], [lorry], [date]) VALUES (8, N'Milk Shorties 80g', N'10', N'Lorry 1   ', CAST(0xBB360B00 AS Date))
     
    Last edited:

    NO_MeRcY

    Well-known member
  • Jun 14, 2010
    5,423
    449
    83
    Singapore
    join ekak damma nam hari ne ban


    select (CAST(a.lorrystock AS INT) - CAST(b.quntityAS INT)) as rsut
    from loading a
    inner join billitem b on a.itemcode = b.itemcode


    casting waradi nam hadala ganin. mama nikan balala liwwe test kale nah
     
    • Like
    Reactions: ad.hasareli